Adapted from this slashdot thread
Create many little files called "chunks00000" etc. from bigfile that are all just under 10MB in size: split -a 5 -b 10MB -d bigfile chunks
Put the chunks back together: cat * > newbigfile
Do the same, except with compression: tar -zc bigfile | split -a 5 -b 10MB -d - chunks
Put the compressed chunks back together: cat chunks000* | tar -zxO > newbigfile
Showing posts with label linux. Show all posts
Showing posts with label linux. Show all posts
Tuesday, January 12, 2010
Friday, October 10, 2008
wmctrl and friends
Tuesday, June 17, 2008
HOWTO Swap caps lock and escape keys in Linux
Caps lock takes up way too much space on a keyboard for how little (never) one presses it. Esc is a very useful key that gets pressed a lot (especially for vi users) but is rather far away and takes more effort to press in the corner of the keyboard. Here is how to switch the functionality of the two keys (solution adapted from the xmodmap manpage) in Linux.
Create a file called .Xmodmap in your home directory. Put the following text in the file:
!
! Swap Caps_Lock and Escape
!
remove Lock = Caps_Lock
remove Control = Escape
keysym Escape = Caps_Lock
keysym Caps_Lock = Escape
add Lock = Caps_Lock
add Control = Escape
Next time you log in, these settings should stick. If you want to switch the keys manually instead of on startup, run xmodmap .Xmodmap to do so. Loading the file again after you have loaded it once will switch the keys back to their original functionalities.
Btw, an informative discussion of all of this X customization stuff is found in chapter 6 of Unix Power Tools.
Create a file called .Xmodmap in your home directory. Put the following text in the file:
!
! Swap Caps_Lock and Escape
!
remove Lock = Caps_Lock
remove Control = Escape
keysym Escape = Caps_Lock
keysym Caps_Lock = Escape
add Lock = Caps_Lock
add Control = Escape
Next time you log in, these settings should stick. If you want to switch the keys manually instead of on startup, run xmodmap .Xmodmap to do so. Loading the file again after you have loaded it once will switch the keys back to their original functionalities.
Btw, an informative discussion of all of this X customization stuff is found in chapter 6 of Unix Power Tools.
Thursday, April 19, 2007
iPod + Amarok
Using your iPod with Ubuntu is disgustingly easy. As a Linux user, I was almost disappointed... no config files to edit? No dependencies to chase down? No bugs to fix? Nope, Ubuntu and the Amarok music player make everything simple. Here, I will detail how to use Amarok with your iPod on an Ubuntu system. I'm using Ubuntu Feisty Fawn 7.04 (just installed today!), a fourth-generation iPod and Amarok version 1.4.5.
First install Amarok with sudo aptitude install amarok (and with aptitude, not apt-get). If you want Amarok to be useful with most file formats (such as mp3) it would be a good idea to install proprietary codecs as well: sudo aptitude install gstreamer0.10-ffmpeg gstreamer0.10-gl gstreamer0.10-plugins-base gstreamer0.10-plugins-good gstreamer0.10-plugins-bad gstreamer0.10-plugins-bad-multiverse gstreamer0.10-plugins-ugly gstreamer0.10-plugins-ugly-multiverse libxine-extracodecs w32codecs
Now that those monster installs are finished, you can go ahead and connect your iPod. If it automatically shows up on your desktop as a little iPod icon, great! If not, check out this thread for more detailed info. When I popped in my iPod, Amarok did me one better and recognized the device, popping up a little dialog asking me what kind of player it was. When this happens, you should select Apple iPod Media Device in the drop-down box. There are a few more options you can set regarding the device -- check out Settings->Configure Amarok->Media Devices in the Amarok toolbar menu. (If this explanation was too complicated for you, there's a guide with nice pictures here describing a slightly different way of going about things.)
To add files to the iPod, go to the Collection tab on the left and highlight whatever you want to transfer to the iPod in the left frame. Right click on it and select Transfer to Media Device. Then go to the Devices tab (with the little iPod logo) and hit Transfer at the top to transfer your files. When you're done transferring files, hit Disconnect at the top. If you're lucky, Amarok will unmount the device for you. If not, you'll have to right click on the desktop icon of the iPod and unmount it that way. I asked in the Amarok IRC channel if it was possible to sync the iPod and apparently it's not... for now, just delete everything off of the iPod and put the new stuff back on, as time consuming as that may be.
There are some other things you can do in Amarok to tweak the settings for the iPod. In the Devices tab under the (usually hidden) iPod menu you can set the model of your iPod. This is used for advanced support such as photo and video copying.
It's annoying that Rhythmbox, the default GNOME music application, launches whenever you connect your iPod. To disable this, go to Preferences->Removable Drives and Media->Multimedia->Portable Music Players and disable Play music files when connected. Just doing this will make a window open up in Nautilus every time you insert a removable drive, including an iPod. To turn this off, go to the Storage tab and uncheck Browse removable media when inserted.
Links
First install Amarok with sudo aptitude install amarok (and with aptitude, not apt-get). If you want Amarok to be useful with most file formats (such as mp3) it would be a good idea to install proprietary codecs as well: sudo aptitude install gstreamer0.10-ffmpeg gstreamer0.10-gl gstreamer0.10-plugins-base gstreamer0.10-plugins-good gstreamer0.10-plugins-bad gstreamer0.10-plugins-bad-multiverse gstreamer0.10-plugins-ugly gstreamer0.10-plugins-ugly-multiverse libxine-extracodecs w32codecs
Now that those monster installs are finished, you can go ahead and connect your iPod. If it automatically shows up on your desktop as a little iPod icon, great! If not, check out this thread for more detailed info. When I popped in my iPod, Amarok did me one better and recognized the device, popping up a little dialog asking me what kind of player it was. When this happens, you should select Apple iPod Media Device in the drop-down box. There are a few more options you can set regarding the device -- check out Settings->Configure Amarok->Media Devices in the Amarok toolbar menu. (If this explanation was too complicated for you, there's a guide with nice pictures here describing a slightly different way of going about things.)
To add files to the iPod, go to the Collection tab on the left and highlight whatever you want to transfer to the iPod in the left frame. Right click on it and select Transfer to Media Device. Then go to the Devices tab (with the little iPod logo) and hit Transfer at the top to transfer your files. When you're done transferring files, hit Disconnect at the top. If you're lucky, Amarok will unmount the device for you. If not, you'll have to right click on the desktop icon of the iPod and unmount it that way. I asked in the Amarok IRC channel if it was possible to sync the iPod and apparently it's not... for now, just delete everything off of the iPod and put the new stuff back on, as time consuming as that may be.
There are some other things you can do in Amarok to tweak the settings for the iPod. In the Devices tab under the (usually hidden) iPod menu you can set the model of your iPod. This is used for advanced support such as photo and video copying.
It's annoying that Rhythmbox, the default GNOME music application, launches whenever you connect your iPod. To disable this, go to Preferences->Removable Drives and Media->Multimedia->Portable Music Players and disable Play music files when connected. Just doing this will make a window open up in Nautilus every time you insert a removable drive, including an iPod. To turn this off, go to the Storage tab and uncheck Browse removable media when inserted.
Links
Friday, April 06, 2007
My .exrc file (vi/m) and then some
What follows is my .exrc file for various versions of vi, and some more related stuff. I have yet to look through the vim documentation exhasutively to see if there are any more useful options -- this is just stuff I have gleaned from random places on the Internet and from friends.
Plain vanilla vi (as on Solaris)
set nu " show line numbers
set ts=4 " tabs take up four columns
set sw=4 " set shiftwidth (>> or <<) to 4 columns set showmatch " show matches of ()'s, {}'s, and []'s
set showmode " show what mode (e.g. INSERT) you're in
set autoindent " indent to the extent of the previous line
Vim:
syntax enable " enables syntax highlighting
set nu " show line numbers
set ts=4 " tabs take up four columns
set sw=4 " set shiftwidth (>> or <<) to 4 columns
set title " sets title of terminal in menubar to that of file currently being edited
set expandtab " tabs aren't really tabs, but many spaces
set softtabstop=4 " delete four spaces when you delete a "tab"
set ignorecase " perform case-insensitive searches...
set smartcase " ... unless there are capitalized characters in the search pattern
set mousehide " hide the mouse when editing
set exrc " eliminates the possibility of another .exrc getting confused with mine on multi-user systems
set backspace=indent,eol,start "explicitly makes the backspace work when at the beginning of a line
set bg=light "this almost always looks better -- take this out or set it to dark if things look funny
set nohlsearch "no annoying search highlighting
" for common typos
command! Q quit
command! W write
command! Wq wq
Vim Python
set autoindent " indent to the extent of the previous line
Vim C/C++/Java
set cindent " indenting for C-style languages
set showmatch " show matches of ()'s, {}'s, and []'s
For Text (Vim 7.0 only)
setlocal spell spelllang=en_us " English(US) spellcheck on (Vim 7.x only)
set tw=0 wrap linebreak " don't split words between lines, only wrap at end of word
"lots of abbreviations (varies depending on the subject material)
ab STIA Science, Technology and International Affairs
How to produce nicely formatted C code in Vim (From p.221 of Learning the vi editor):
set nocp incsearch
set cinoptions=:0,p0,t0
set cinwords=if,else,while,do,for,switch,case
set formatoptions=tcqr
set cindent
syntax on
source ~/.exrc
Options set when vim 6.4/7 starts on my system (Ubuntu Linux):
helplang=en " language to display help in
ruler " show row and column in bottom right
ttyfast " indicates a fast terminal connection
viminfo='20,"50 " configuration info
history=50 " number of : commands and previous search patters to be remembered
scroll=32 " number of lines to scroll with CRTL-U and CTRL-D commands
ttymouse=xterm2 " mouse codes
backspace=indent,eol,start "explicitly makes the backspace work when at the beginning of a line
fileencodings=ucs-bom,utf-8,latin1 " list of character encodings considered when starting to edit a file
printoptions=paper:letter " controls format and output of printing
runtimepath=~/.vim,/usr/share/vim/addons,/usr/share/vim/vimfiles,/usr/share/vim/vimcurrent,/usr/share/vim/vimfiles/after,/usr/share/vim/addons/after,~/.vim/after " list of directories which will be searched for runtime files
suffixes=.bak,~,.swp,.o,.info,.aux,.log,.dvi,.bbl,.blg,.brf,.cb,.ind,.idx,.ilg,.inx,.out,.toc " Files with these suffixes get a lower priority when multiple files match a wildcard.
Cool stuff that I have seen various places but I didn't find particularly useful (maybe someone else will):
set list "replaces all EOLs and TABs with $ and ^I
"auto-complete of brackets
inoremap [ [] <left>
inoremap ( () <left>
inoremap { {} <left>
inoremap " "" <left>
inoremap ' '' <left>
To see the options vi(m) has enabled, enter :set
To get help with options in Vim, enter :help set or :set all for regular vi
Or just :help for the help contents... Vim has excellent documentation
Links
Plain vanilla vi (as on Solaris)
set nu " show line numbers
set ts=4 " tabs take up four columns
set sw=4 " set shiftwidth (>> or <<) to 4 columns set showmatch " show matches of ()'s, {}'s, and []'s
set showmode " show what mode (e.g. INSERT) you're in
set autoindent " indent to the extent of the previous line
Vim:
syntax enable " enables syntax highlighting
set nu " show line numbers
set ts=4 " tabs take up four columns
set sw=4 " set shiftwidth (>> or <<) to 4 columns
set title " sets title of terminal in menubar to that of file currently being edited
set expandtab " tabs aren't really tabs, but many spaces
set softtabstop=4 " delete four spaces when you delete a "tab"
set ignorecase " perform case-insensitive searches...
set smartcase " ... unless there are capitalized characters in the search pattern
set mousehide " hide the mouse when editing
set exrc " eliminates the possibility of another .exrc getting confused with mine on multi-user systems
set backspace=indent,eol,start "explicitly makes the backspace work when at the beginning of a line
set bg=light "this almost always looks better -- take this out or set it to dark if things look funny
set nohlsearch "no annoying search highlighting
" for common typos
command! Q quit
command! W write
command! Wq wq
Vim Python
set autoindent " indent to the extent of the previous line
Vim C/C++/Java
set cindent " indenting for C-style languages
set showmatch " show matches of ()'s, {}'s, and []'s
For Text (Vim 7.0 only)
setlocal spell spelllang=en_us " English(US) spellcheck on (Vim 7.x only)
set tw=0 wrap linebreak " don't split words between lines, only wrap at end of word
"lots of abbreviations (varies depending on the subject material)
ab STIA Science, Technology and International Affairs
How to produce nicely formatted C code in Vim (From p.221 of Learning the vi editor):
set nocp incsearch
set cinoptions=:0,p0,t0
set cinwords=if,else,while,do,for,switch,case
set formatoptions=tcqr
set cindent
syntax on
source ~/.exrc
Options set when vim 6.4/7 starts on my system (Ubuntu Linux):
helplang=en " language to display help in
ruler " show row and column in bottom right
ttyfast " indicates a fast terminal connection
viminfo='20,"50 " configuration info
history=50 " number of : commands and previous search patters to be remembered
scroll=32 " number of lines to scroll with CRTL-U and CTRL-D commands
ttymouse=xterm2 " mouse codes
backspace=indent,eol,start "explicitly makes the backspace work when at the beginning of a line
fileencodings=ucs-bom,utf-8,latin1 " list of character encodings considered when starting to edit a file
printoptions=paper:letter " controls format and output of printing
runtimepath=~/.vim,/usr/share/vim/addons,/usr/share/vim/vimfiles,/usr/share/vim/vimcurrent,/usr/share/vim/vimfiles/after,/usr/share/vim/addons/after,~/.vim/after " list of directories which will be searched for runtime files
suffixes=.bak,~,.swp,.o,.info,.aux,.log,.dvi,.bbl,.blg,.brf,.cb,.ind,.idx,.ilg,.inx,.out,.toc " Files with these suffixes get a lower priority when multiple files match a wildcard.
Cool stuff that I have seen various places but I didn't find particularly useful (maybe someone else will):
set list "replaces all EOLs and TABs with $ and ^I
"auto-complete of brackets
inoremap [ [] <left>
inoremap ( () <left>
inoremap { {} <left>
inoremap " "" <left>
inoremap ' '' <left>
To see the options vi(m) has enabled, enter :set
To get help with options in Vim, enter :help set or :set all for regular vi
Or just :help for the help contents... Vim has excellent documentation
Links
My .bashrc file
export TERM="xterm-color" # xterm terminal emulation (with color -- be sure to put at top of file on Ubuntu)
export PYTHONSTARTUP="$HOME/.pythonrc.py" # python startup file
set -o vi # sets vi command-line editing mode
bind -m vi-command -r 'v' # so that every time you hit v in command mode, an editor doesn't launch
ulimit -c unlimited # dump core files, no matter how big they are
export EDITOR="vi" #use vi as the default editor for some commands, like "fc"
alias screen='TERM=screen screen' # workaround for screen backspace bug
alias d="date '+%r -- %A, %D'" # human-readable date output
alias ll="ls -lh" # long listing (with human-readable file sizes)
alias lr="ls -ltrh" # list by reverse modification time
alias la="ls -Ah" # list hidden files (except implied . and ..)
alias <name>="cd <important>" # get to important directories fast
alias <name>="ssh <login>@<important>" # log into oft-used remote machines fast
The following I only enable on Solaris systems:
export PAGER="less" #uses less to view manpages instead of more
Links:
export PYTHONSTARTUP="$HOME/.pythonrc.py" # python startup file
set -o vi # sets vi command-line editing mode
bind -m vi-command -r 'v' # so that every time you hit v in command mode, an editor doesn't launch
ulimit -c unlimited # dump core files, no matter how big they are
export EDITOR="vi" #use vi as the default editor for some commands, like "fc"
alias screen='TERM=screen screen' # workaround for screen backspace bug
alias d="date '+%r -- %A, %D'" # human-readable date output
alias ll="ls -lh" # long listing (with human-readable file sizes)
alias lr="ls -ltrh" # list by reverse modification time
alias la="ls -Ah" # list hidden files (except implied . and ..)
alias <name>="cd <important>" # get to important directories fast
alias <name>="ssh <login>@<important>" # log into oft-used remote machines fast
# prevent myself from doing stupid things with vi
function vi {
if [ ! -e "$1" ]; then
if [ "$1" == "" ]; then
vim
else
vim "$1"
fi
elif [ -d "$1" ]; then
cd "$1"
elif [[ -c "$1" || -b "$1" || -p "$1" || -S "$1" || ! -r "$1" ]]; then
file "$1"
else
vim "$1"
fi
}
The following I only enable on Solaris systems:
export PAGER="less" #uses less to view manpages instead of more
Links:
Wednesday, April 04, 2007
Common Bash Tasks
I don't use Bash for much scripting. Usually, if I have to open up a file to write a script, it will be done in Python. However, the less I have to do that for mundane tasks that can be accomplished on the command line with Bash, the better. This entry may not have much in it now, but every time I do something cool/useful/time-saving in Bash from now on, it'll go on here.
Common Tasks
Common Tasks
- Rename *.foo files to *.bar files: for i in *.foo; do mv $i ${i%.foo}.bar; done (BashFAQ)
- Rename foo.* files to bar.* files: for i in foo.*; do mv $i bar.${i#foo.}; done (also check out the perl regex-based rename Linux utility)
- Do something to multiple arguments: for i in arg1 arg2 arg3; do echo $i; done
- Print 0 through 9 on separate lines: for i in {0..9}; do echo $i; done
- Flatten output onto one line: <Multi-line output> | xargs (10 habits)
- GNU Bash Reference Manual
- Bash Manpage
- BashFaq Bash FAQs and answers
- Bash Pitfalls common mistakes
- Advanced Bash Scripting Guide Everything you would want to know about Bash scripting
- Bash Guide for Beginners A beginner's guide to Bash, some shell examples
- 10 Good UNIX Habits Advanced tips on the command line
Labels:
bash,
command line,
linux,
scripting,
shell
Saturday, January 20, 2007
UNIX status commands on Solaris
Proc tools:
- pflags Print the /proc tracing flags, the pending and held signals, and other /proc status information for each lwp in each process.
- pcred Print or set the credentials (effective, real, saved UIDs and GIDs) of each process.
- pldd List the dynamic libraries linked into each process, including shared objects explicitly attached using dlopen(3C). See also ldd(1).
- psig List the signal actions and handlers of each process. See signal.h(3HEAD).
- pstack Print a hex+symbolic stack trace for each lwp in each process.
- pfiles Report fstat(2) and fcntl(2) information for all open files in each process. In addition, a path to the file is reported if the information is available from /proc/pid/path. This is not necessarily the same name used to open the file. See proc(4) for more information.
- pwdx Print the current working directory of each process.
- pstop Stop each process (PR_REQUESTED stop).
- prun Set each process running (inverse of pstop).
- pwait Wait for all of the specified processes to terminate.
- ptime Time the command, like time(1), but using microstate accounting for reproducible precision. Unlike time(1), children of the command are not timed.
- arch display system architecture (i86pc)
- uname print name of current system (SunOS)
- pagesize display the size of pages of memory
- iostat report I/O stats for terminal, disk, tape, etc
- vmstat report virtual memory statistics
- mpstat report CPU statistics
- busstat report bus-related support statistics
- lsof list open files (sockets (lsof -i), etc.) Introductory lsof examples
- nohup run a command immune to hangups
- kstat display kernel statistics
Saturday, October 21, 2006
Linux PCI Wireless cards (and the bcm43xx driver)
It's a pain in the butt when manufacturers of PCI wireless cards don't release a driver to go with their hardware. Case in point: broadcom, whose card I purchased. Luckily, there is a hacked driver available from the community.
Links:
Note to self: whatever I do, do NOT use ndiswrapper for wireless drivers. All the kernel hackers tell me it's bad... and, they were right. I believe it attempts to load the Windows driver on top of a layer that enables the cooperation of the hardware and the Windows driver. When I tried to use it, it crashed GNOME. Grrr...
The jury's out on whether this actually works or not (I have yet to get this desktop in range of a usable wireless signal) but I can iwlist eth0 scan for stuff and get results back so I'm optimistic...
Update: this thing works (most of the time). Sometimes it will inexplicably lose the signal and I'll have to connect again. Not the biggest deal in the world, but still pretty annoying.
Links:
- Ubuntu docs wireless troubleshooting guide -- very good
- Ubuntu docs guide for using the bcm43xx class of cards
- Another (worse) guide for bcm's
Note to self: whatever I do, do NOT use ndiswrapper for wireless drivers. All the kernel hackers tell me it's bad... and, they were right. I believe it attempts to load the Windows driver on top of a layer that enables the cooperation of the hardware and the Windows driver. When I tried to use it, it crashed GNOME. Grrr...
The jury's out on whether this actually works or not (I have yet to get this desktop in range of a usable wireless signal) but I can iwlist eth0 scan for stuff and get results back so I'm optimistic...
Update: this thing works (most of the time). Sometimes it will inexplicably lose the signal and I'll have to connect again. Not the biggest deal in the world, but still pretty annoying.
Wednesday, September 06, 2006
Everything you've ever wanted to know about GNOME
About.com's GNOME Desktop User Guide
Some useful keyboard shortcuts from another About.com page:
UPDATE: To get Nautilus in GNOME to have the location bar (like default in KDE): Open a Nautilis window->Edit->Preferences->Behavior->Always use text-entry location bar ... There's a host of other useful display/behavior options there, too.
Some useful keyboard shortcuts from another About.com page:
- Alt+Tab Switch between windows. A list of windows that you can select is displayed. Release the keys to select a window. You can press the Shift key to cycle through the windows in reverse order.
- Alt+F4 Close the currently focused window.
- Alt+F5 Unmaximize the current window, if it is maximized.
- Alt+F7 Move the currently focused window. After pressing this shortcut, you can move the window using either the mouse or the arrow keys. To finish the move, click the mouse or press any key on the keyboard.
- Alt+F8 Resize the currently focused window. After pressing this shortcut, you can resize the window using either the mouse or the arrow keys. To finish the resize, click the mouse or press any key on the keyboard.
- Alt+F9 Minimize the current window.
- Alt+F10 Maximize the current window.
- Alt+spacebar Open the window menu for the currently selected window. The window menu allows you to perform actions on the window, such as minimizing, moving between workspaces, and closing.
- Shift+Ctrl+Alt+Arrow keys Move the current window to another workspace in the specified direction.
- Ctrl++ enlarge the screen/text
- Ctrl+- shrink the screen/text
UPDATE: To get Nautilus in GNOME to have the location bar (like default in KDE): Open a Nautilis window->Edit->Preferences->Behavior->Always use text-entry location bar ... There's a host of other useful display/behavior options there, too.
Saturday, July 29, 2006
Waseem comes to the Linux/Wireless rescue
Waseem just helped me configure my wireless on my Compaq laptop (that is now running Ubuntu Dapper Drake). Any network that is publicly accessible will be viewable (if, of course the wireless card/network is enabled) in the drop-down box in Network Setting --> wireless --> Properties. It will not automatically connect to any network it senses. Here is some command line wizardry to help configure wireless settings:
- Need to know name of network interface -- type in iwconfig to find that out (usually its name is eth1 or the like)
- Then you want to scan the nearby places to see what networks you can use -- iwlist < network > scan returns a list of potentially usable networks... it also tells you if you need an encyption key (password) to access the network
- To tell your network card that you want to use a certain network -- iwconfig <network> essid <name>
- Now to tell it the password (if neccesssary) -- iwconfig <network> key <password> (Waseem isn't sure if this is the same accross networks... some require hex keys, some require ASCII keys, etc.)
- Now you need to tell Linux "I want to start using this connection" -- ifconfig <network> up (of course, to turn it off, the same command with down instead of up)
- To get an IP address using DHCP -- dhclient < network >
- If you're not using DHCP, you need to tell ifconfig about the IP address request (Waseem isn't sure how to do this)
- iwconfig -- configure a wireless network interface
- ifconfig -- configure a network interface
- iwlist -- get more detailed information from a wireless interface
- Tell your interface that you want to roam on a network: iwconfig <network> mode Managed
- Specify the connection point: iwconfig <network> ap <MAC address>
- From here it's the same as any wireless connection: ifconfig <network> up
- Request an IP address: dhclient <network>
Subscribe to:
Posts (Atom)