Unit Tricks and Tips

alias l='ls -AFC'

-A all files except . and .. -F add * to the end of executables, / to dirs, and @ to symlinks -C multi-column output

By the way, if you are an old time Unix geek annoyed by how ls now does a case-insensitive sort on filenames who wants the old behaviour back, add

export LANG=C

to your .bashrc.

alias ll='ls -la'

alias lll='ls -laL'

-l long format listing -a all files (including . and ..) -L follow symlinks, and list on the underlying file instead of the link

alias lr='ls -ltra'

-t sort by last modified time on files -r reverse the sort order, so that newest come last

ls -li

-i list inodes

less -MQseai

-M like more, only more so -Q quiet (no terminal bells, ever) -s squeeze multiple blank lines into one -a start next search on next page -i ignore case in searches

g go to line 1 G go to end of file N next file P prev file

m[a-z] mark the file '[a-z] return to mark F follow

export LESS=MQseai


alias man='man -a'

-a display ALL matching man pages

apropos (or man -k)

man pages whose summary matches the input


-name \*.html finds files that end in .html -iname \*.html as -name, but ignore case -follow follow symlinks -xdev don't cross filesystem boundaries -empty zero-length files and empty directories -newer filename find entries that are newer than filename -perm mode, -mode, +mode file permissions are exactly, all, or any of the bits in mode

Learn to think about file permissions in octal.

-type <char> only look at <d>irectories, <f>iles, <l>inks, and so on -print print matching names -print0 print matching names delimited by \0

Read the man page for find. Play with it. It will pay off.

xargs <cmd> <cmd-args>

Take lines from stdin, and comvert them into command args for cmd.

-0 use \0 as input separator, instead of \n

find and xargs are made for each other.

cpio -pdumv

copy entire directory trees, preserving everything

find and cpio are also made for each other

revmv, revln, revcp – shell scripts to use with find and xargs

symlinks versus hard links

symlinks pros – can cross filesystems cons – can have the rug pulled out from under them

hard links pros – can't have the rug pulled out from under them cons == can't cross filesystems

df, df -i

display free space, or free inodes

-h human readable -k kilobytes -m megabytes


display usage

-s summarise -c total -x don't cross filesystems -h human readable -k kilobytes -m megabytes


sort files

-b skip leading blanks -n sort numerically -k<n> sort on field n -r reverse the sort order -u uniq lines only

Prefer to sort things so that the interesting bits come at the end.


get unique entries in a file

-c count occurrences -d duplicated lines only -u unique lines only


cut the lines of a file into fields

-c<n>{-<n>} columns -f<n>{-<n>} fields -d<c> delimiter


paste lines from several input files together


grep files with multi-line records

-d<delim> record delimiter


list open files and network connections (run as root)

-c<command> list only <command>


show the network config for a box


show the network status

-r show the routing table -g show multicast group membership

iostat vmstat sar

Show the disk i/o, vm activity, and system activity report

Specify a delay interval and a repeat count if desired


print process table as a tree


get the basename of a file


get the directory name of a file

touch && >

set the last modified time to now. touch will also create the file if it does not exist. > will zero a file, or create it if it does not exist.


hex dump a file


dump an object file

-x dump all sections –demangle turn C++ mangled names back to human readable names


list dynamic object dependencies

namei realpath

find the real file


time a command


split the pipe. send stdin to both stdout, and to a file.

-a append to a file


repeatedly output the same string


print stdin in multicolumn format

tput clear

clear the screen


diff three files (e.g. diff3 mine original yours)

tr <string1> <string2>

translate characters in string1 to characters in string2

-s squeeze multiple occurrences together -c complement the first string -d delete characters in string1

sum && md5sum

compute a simple checksum, or an md5checksum


print a calendar

dc && bc

two quick and simple calculators

tail && head

print the last/first -N lines of a file

tail -f follows a file waiting for new data


output a sequence of numbers

hostname, uname, /etc/redhat-release

what is the hostname of the box, the unix name, and the redhat release

nice && renice

run a command at a lower priority, or change a running command's priority


identify what kind of file this is


how long has the system been up, and what is the load average


start or reconnect to virtual screens

kill && killall

send a signal to running processes

-HUP send a hangup -KILL send a KILL (-9) to a process


print stats on an inode


trace all system calls from a running process


compare two files, and produce three columns: uniq to file1, uniq to file2, and comm-on to both


interprocess communication statistics

-l show limits


unixtricksandtips.txt · Last modified: 2014/10/26 01:52 (external edit)
CC Attribution-Share Alike 3.0 Unported
www.chimeric.de Valid CSS Driven by DokuWiki do yourself a favour and use a real browser - get firefox!! Recent changes RSS feed Valid XHTML 1.0