User Tools

Site Tools


Linux Commands


"Maintain symbolic links determining default commands" (manages links in the /etc/alternatives directory). The command is called update-alternatives on Debian systems, and may be available as alternatives on other systems (e.g. RHEL).

There is a GUI frontend to update-alternatives called galternatives.


  • Ctrl+R: reverse search; enter to accept, Ctrl+R to go to the previous match, tab to select the current match for editing


Turn Vim into a bash IDE

Compiling programs from source

When Fred compiles an application from source, he creates a file called DoConfigure so that he can remember what options he used. I was thinking something like (chmoded +x so that it stops the shell completion from filling out "./configure").

'less' options for paging like git

By default, git uses less for paging, and it sets the LESS environment variable to FRSX 1), which is equivalent to calling less -FRSX. To get similar behavior from, for instance, grep or ls, one would want to specify the option --color=always to force them to pass the color escape sequences through the pipe to less.

less opens binaries (with help from lesspipe)

I just noticed it in my .bashrc. lesspipe lets you type things like this:

less foo.tar.gz  #list the contents of the archive
less bar.png     #maybe do something useful if ImageMagick is installed?

Anyway, this works by default in Ubuntu. man lesspipe gives more details, and lists file types:

*.deb, *.udeb
*.gif, *.jpeg, *.jpg, *.pcd, *.png, *.tga, *.tiff, *.tif
*.iso, *.raw, *.bin
*.lha, *.lzh
*.rar, *.r[0-9][0-9]
*.tar.gz, *.tgz, *.tar.z, *
*.gz, *.z, *.dz
*.jar, *.war, *.xpi, *.zip


Change mode/ownership when mounting Samba shares

Finally found at

  • file_mode=arg e.g. file_mode=0600
  • dir_mode=arg e.g. dir_mode=0700
  • uid=arg
  • gid=arg

Also see

Mount an ISO file

mount -o loop -t iso9660 file.iso /mnt/test

Mount existing LVM

Ubuntu needs the lvm2 package.

Here are some commands, including an example mount command:

vgchange -a y
mount -t ext3 /dev/VolGroup00/LogVol00 /media/mylvm


  • q: query packages
    • a: all packages
    • i: display package information
    • l: list files in package
    • Finding what package a file belongs to: rpm -q --whatprovides /path/to/file


Find a package:

rpm -qa | grep SOMETHING

Information about a package:


Install a package (verbose, progress bar):

rpm -Uhiv RPM_FILE


See SSH.

GNU tar

The --exclude option comes before the path but after the filename, if specified. For example:

tar cvfj foo.tar.bz2 --exclude /home/foo/bar /home/foo


Change timezone:

dpkg-reconfigure tzdata

lsb_release for distribution information

lsb_release -rd
lsb_release -a

For example:

Description:	Ubuntu 8.10
Release:	8.10

Find text in files (current directory)

Find text in files, ignore binary files; works with spaces in path by separating arguments with '\0' instead of whitespace.


find . -print0 | xargs -0 grep --binary-files=without-match 'TEXT'
find . -print0 | xargs -0 grep --binary-files=without-match --color=yes 'TEXT'
find . -print0 | xargs -0 grep --binary-files=without-match --color=yes 'TEXT' | less -r
find . -print0 | xargs -0 grep --binary-files=without-match --color=yes 'TEXT' | grep -v '/.svn/'

Hardware Info

No hwinfo in the repositories, but lshw (and lshw-gui) are available in the EPEL repository, for RHEL5 anyway.

Ethernet Speed

To see negotiated ethernet speed:

ethtool eth0


dmesg | grep eth0

Both should show if you have a 1000 Mbps / gigabit connection. mii-tool won't show gigabit.

Use 'perl' like 'sed'

Perl can be used for one-liners like a more powerful sed. For example:

perl -p -i.bak -e 's/; / \&\& /g' <INPUT FILE>

The -i makes it make the changes in-place. Remove the '.bak' to forgo making a backup.

info/linuxcommands.txt · Last modified: 2010-12-09 20:09 by sam