You are on page 1of 24

Linux Commands Summary

Part I.................................................................................................................................................2 Command....................................................................................................................................2 dir navigation..............................................................................................................................2 file searching...............................................................................................................................2 archives and compression...........................................................................................................3 rsync (Network efficient file copier: Use the --dry-run option for testing)................................3 ssh (Secure SHell).......................................................................................................................3 wget (multi purpose download tool)...........................................................................................4 networking (Note ifconfig, route, mii-tool, nslookup commands are obsolete).........................4 windows networking (Note samba is the package that provides all this windows specific networking support)....................................................................................................................5 text manipulation (Note sed uses stdin and stdout. Newer versions support inplace editing with the -i option)........................................................................................................................5 set operations (Note you can export LANG=C for speed. Also these assume no duplicate lines within a file)................................................................................................................................6 math.............................................................................................................................................6 calendar.......................................................................................................................................6 locales..........................................................................................................................................7 recode (Obsoletes iconv, dos2unix, unix2dos)............................................................................7 CDs..............................................................................................................................................7 disk space (See also FSlint)........................................................................................................8 monitoring/debugging.................................................................................................................8 system information (see also sysinfo) ('#' means root access is required)..................................9 interactive (see also linux keyboard shortcuts)...........................................................................9 Part II...............................................................................................................................................9 Command..................................................................................................................................10 Low impact admin....................................................................................................................10 Interactive monitoring...............................................................................................................10 Useful utilities...........................................................................................................................10 Networking................................................................................................................................11 Notification................................................................................................................................11 Better default settings (useful in your .bashrc).........................................................................11 Useful functions/aliases (useful in your .bashrc)......................................................................11 Multimedia................................................................................................................................12 DVD..........................................................................................................................................12 Unicode.....................................................................................................................................12 Development.............................................................................................................................13 udev...........................................................................................................................................13 Extended Attributes (Note you may need to (re)mount with "acl" or "user_xattr" options)....13 BASH specific...........................................................................................................................13 Multicore...................................................................................................................................14 Brief overview of Unix and Linux commands..............................................................................14

TF4BRA1

1 / 24

26 sept. 2012

Linux Commands Summary

Part I
This is a linux command line reference for common operations from http://www.pixelbeat.org/cmdline.html. Examples marked with are valid/safe to paste without modification into a terminal, so you may want to keep a terminal window open while reading this so you can cut & paste. Description Show commands pertinent to string. See also threadsafe make a pdf of a manual page Show full path name of command See how long a command takes Start stopwatch. Ctrl-d to stop. See also sw

Command
apropos whatis man -t ascii | ps2pdf - > ascii.pdf
which command time command

time cat

dir navigation
cd cd
(cd dir && command)

pushd .

Go to previous directory Go to $HOME directory Go to dir, execute command and return to current dir Put current dir on stack so you can popd back to it

file searching
alias l='ls -l --color=auto' ls -lrt ls /usr/bin | pr -T9 -W$COLUMNS
find -name '*.[ch]' | xargs grep -E 'expr' find -type f -print0 | xargs -r0 grep -F 'example' find -maxdepth 1 -type f | xargs grep -F 'example' find -maxdepth 1 -type d | while read dir; do echo $dir; echo cmd2; done

quick dir listing List files by date. See also newest and find_mm_yyyy Print in 9 columns to width of terminal Search 'expr' in this dir and below. See also findrepo Search all regular files for 'example' in this dir and below Search all regular files for 'example' in this dir Process each item with multiple commands (in while loop) Find files not readable by all (useful for web site) Find dirs not accessible by all (useful for web site) Search cached index for names. This re is like 26 sept. 2012

find -type f ! -perm -444 find -type d ! -perm -111 locate -r 'file[^/]*\.txt' TF4BRA1

2 / 24

Linux Commands Summary glob *file*.txt Quickly search (sorted) dictionary for prefix Highlight occurances of regular expression in dictionary

look reference /usr/share/dict/words


grep --color reference

archives and compression


gpg -c file gpg file.gpg tar -c dir/ | bzip2 > dir.tar.bz2 bzip2 -dc dir.tar.bz2 | tar -x tar -c dir/ | gzip | gpg -c | ssh user@remote 'dd of=dir.tar.gz.gpg' find dir/ -name '*.txt' | tar -c --files-from=- | bzip2 > dir_txt.tar.bz2 find dir/ -name '*.txt' | xargs cp -a --target-directory=dir_txt/ --parents ( tar -c /dir/to/copy ) | ( cd /where/to/ && tar -x -p ) ( cd /dir/to/copy && tar -c . ) | ( cd /where/to/ && tar -x -p ) ( tar -c /dir/to/copy ) | ssh -C user@remote 'cd /where/to/ && tar -x -p' dd bs=1M if=/dev/sda | gzip | ssh user@remote 'dd of=sda.gz'

Encrypt file Decrypt file Make compressed archive of dir/ Extract archive (use gzip instead of bzip2 for tar.gz files) Make encrypted archive of dir/ on remote machine Make archive of subset of dir/ and below Make copy of subset of dir/ and below Copy (with permissions) copy/ dir to /where/to/ dir Copy (with permissions) contents of copy/ dir to /where/to/ Copy (with permissions) copy/ dir to remote:/where/to/ dir Backup harddisk to remote machine

rsync (Network efficient file copier: Use the --dry-run option for testing)
rsync -P rsync://rsync.server.com/path/to/file file rsync --bwlimit=1000 fromfile tofile rsync -az -e ssh --delete ~/public_html/ remote.com:'~/public_html' rsync -auz -e ssh remote:/dir/ . && rsync -auz -e ssh . remote:/dir/

Only get diffs. Do multiple times for troublesome downloads Locally copy with rate limit. It's like nice for I/O Mirror web site (using compression and encryption) Synchronize current directory with remote one

ssh (Secure SHell)


ssh $USER@$HOST command

ssh -f -Y $USER@$HOSTNAME xeyes

Run command on $HOST as $USER (default command=shell) Run GUI command on $HOSTNAME as $USER 3 / 24 26 sept. 2012

TF4BRA1

Linux Commands Summary Copy with permissions to $USER's home directory on $HOST Use faster crypto for local LAN. This might scp -c arcfour $USER@$LANHOST: bigfile saturate GigE Forward connections to $HOSTNAME:8080 ssh -g -L 8080:localhost:80 root@$HOST out to $HOST:80 Forward connections from $HOST:1434 in to ssh -R 1434:imap:143 root@$HOST imap:143 Install public key for $USER@$HOST for ssh-copy-id $USER@$HOST password-less log in
scp -p -r $USER@$HOST: file dir/

wget (multi purpose download tool)


http://www.pixelbeat.org/cmdline.html)
wget -c http://www.example.com/large.file wget -r -nd -np -l1 -A '*.jpg' http://www.example.com/dir/ wget ftp://remote/file[1-9].iso/ wget -q -O(cd dir/ && wget -nd -pHEKk

Store local browsable version of a page to the current dir Continue downloading a partially downloaded file Download a set of files to the current directory FTP supports globbing directly

http://www.pixelbeat.org/timeline.html Process output directly


| grep 'a href' | head echo 'wget url' | at 01:00 wget --limit-rate=20k url wget -nv --spider --force-html -i bookmarks.html wget --mirror http://www.example.com/

Download url at 1AM to current dir Do a low priority download (limit to 20KB/s in this case) Check links in a file Efficiently update a local copy of a site (handy from cron)

networking (Note ifconfig, route, mii-tool, nslookup commands are obsolete)


ethtool eth0 ethtool --change eth0 autoneg off speed 100 duplex full iwconfig eth1 iwconfig eth1 rate 1Mb/s fixed

Show status of ethernet interface eth0 Manually set ethernet interface speed Show status of wireless interface eth1 Manually set wireless interface speed List wireless networks in range List network interfaces Rename interface eth0 to wan Bring interface eth0 up (or down) List addresses for interfaces Add (or del) ip and mask (255.255.255.0) 26 sept. 2012

iwlist scan ip link show


ip link set dev eth0 name wan ip link set dev eth0 up

ip addr show
ip addr add 1.2.3.4/24 brd + dev eth0

TF4BRA1

4 / 24

Linux Commands Summary ip route show


ip route add default via 1.2.3.254

host pixelbeat.org hostname -i whois pixelbeat.org netstat -tupl netstat -tup

List routing table Set default gateway to 1.2.3.254 Lookup DNS ip address for name or vice versa Lookup local ip address (equivalent to host `hostname`) Lookup whois info for hostname or ip address List internet services on a system List active connections to/from system

windows networking (Note samba is the package that provides all this windows specific networking support)
smbtree
nmblookup -A 1.2.3.4 smbclient -L windows_box mount -t smbfs -o fmask=666,guest //windows_box/share /mnt/share echo 'message' | smbclient -M windows_box

Find windows machines. See also findsmb Find the windows (netbios) name associated with ip address List shares on windows machine or samba server Mount a windows share Send popup to windows machine (off by default in XP sp2)

text manipulation (Note sed uses stdin and stdout. Newer versions support inplace editing with the -i option)
sed 's/string1/string2/g' sed 's/\(.*\)1/\12/g' sed '/ *#/d; /^ *$/d' sed ':a; /\\$/N; s/\\\n//; ta' sed 's/[ \t]*$//' sed 's/\([`"$\]\)/\\\1/g'

Replace string1 with string2 Modify anystring1 to anystring2 Remove comments and blank lines Concatenate lines with trailing \ Remove trailing spaces from lines Escape shell metacharacters active within double quotes Right align numbers Print 1000th line Print lines 10 to 20 Extract title from HTML web page Delete a particular line Sort IPV4 ip addresses Case conversion Filter non printable characters cut fields separated by blanks 26 sept. 2012

{7,\}\)/\1/"

seq 10 | sed "s/^/ sed -n '1000{p;q}' sed -n '10,20p;20q'

/; s/ *\(.\

sed -n 's/.*<title>\ (.*\)<\/title>.*/\1/ip;T;q' sed -i 42d ~/.ssh/known_hosts sort -t. -k1,1n -k2,2n -k3,3n -k4,4n echo 'Test' | tr '[:lower:]'

'[:upper:]'

tr -dc '[:print:]' < /dev/urandom


tr -s '[:blank:]' '\t' </proc/diskstats | cut -f4

TF4BRA1

5 / 24

Linux Commands Summary history | wc -l Count lines

set operations (Note you can export LANG=C for speed. Also these assume no duplicate lines within a file)
sort file1 file2 | uniq sort file1 file2 | uniq -d sort file1 file1 file2 | uniq -u sort file1 file2 | uniq -u join -t'\0' -a1 -a2 file1 file2 join -t'\0' file1 file2 join -t'\0' -v2 file1 file2 join -t'\0' -v1 -v2 file1 file2

Union of unsorted files Intersection of unsorted files Difference of unsorted files Symmetric Difference of unsorted files Union of sorted files Intersection of sorted files Difference of sorted files Symmetric Difference of sorted files

math
echo '(1 + sqrt(5))/2' | bc -l bc -l
seq -f '4/%g' 1 2 99999 | paste -sd-+ | echo 'pad=20; min=64; (100*10^6)/ echo 'pad=20; min=64; print (100E6)/ echo 'pad=20; plot [64:1518] -persist

Quick math (Calculate ). See also bc Calculate the unix way More complex (int) e.g. This shows max FastE packet rate Python handles scientific notation Plot FastE packet rate vs packet size Base conversion (decimal to hexadecimal) Base conversion (hex to dec) ((shell arithmetic expansion)) Unit conversion (metric to imperial) Unit conversion (SI to IEC prefixes) Definition lookup Add a column of numbers. See also add and funcpy

((pad+min)*8)' | bc

((pad+min)*8)' | python

(100*10**6)/((pad+x)*8)' | gnuplot echo 'obase=16; ibase=10; 64206' | bc echo $((0x2dec)) units -t '100m/9.58s' 'miles/hour' units -t '500GB' 'GiB' units -t '1 googol' seq 100 | (tr '\n' +; echo 0) | bc

calendar
cal -3 cal 9 1752 date -d fri '01' ] || exit date --date='25 Dec' +%A
[ $(date -d '12:00 +1 day' +%d) =

Display a calendar Display a calendar for a particular month year What date is it this friday. See also day exit a script unless it's the last day of the month What day does xmas fall on, this year Convert seconds since the epoch (1970-01-01 UTC) to date 6 / 24 26 sept. 2012

date --date='@2147483647'

TF4BRA1

Linux Commands Summary TZ='America/Los_Angeles' date 09:00 next Fri'


date --date='TZ="America/Los_Angeles"

What time is it on west coast of US (use tzselect to find TZ) What's the local time for 9AM next Friday on west coast US

locales
printf "%'d\n" 1234 BLOCK_SIZE=\'1 ls -l echo "I live in `locale territory`" LANG=en_IE.utf8 locale int_prefix {4,\}\)=.*/\1/p') | less
locale -kc $(locale | sed -n 's/\(LC_.\

Print number with thousands grouping appropriate to locale Use locale thousands grouping in ls. See also l Extract info from locale database Lookup locale info for specific country. See also ccodes List fields available in locale database

recode (Obsoletes iconv, dos2unix, unix2dos)


recode -l | less Show available conversions (aliases on each line) recode windows-1252.. Windows "ansi" to local charset (auto does file_to_change.txt CRLF conversion) recode utf-8/CRLF.. file_to_change.txt Windows utf8 to local charset
recode iso-8859-15..utf8 file_to_change.txt recode ../b64 < file.txt > file.b64

Latin9 (western europe) to utf8

Base64 encode recode /qp.. < file.qp > file.txt Quoted printable decode recode ..HTML < file.txt > file.html Text to HTML recode -lf windows-1252 | grep euro Lookup table of characters echo -n 0x80 | recode latin-9/x1..dump Show what a code represents in latin-9 charmap 2/x2..latin-9/x 8/x
echo -n 0x20AC | recode ucsecho -n 0x20AC | recode ucs-2/x2..utf-

Show latin-9 encoding Show utf-8 encoding

CDs
gzip < /dev/cdrom > cdrom.iso.gz mkisofs -V LABEL -r dir | gzip > cdrom.iso.gz mount -o loop cdrom.iso /mnt/dir cdrecord -v dev=/dev/cdrom blank=fast gzip -dc cdrom.iso.gz | cdrecord -v dev=/dev/cdrom cdparanoia -B

Save copy of data cdrom Create cdrom image from contents of dir Mount the cdrom image at /mnt/dir (read only) Clear a CDRW Burn cdrom image (use dev=ATAPI -scanbus to confirm dev) Rip audio tracks from CD to wav files in current dir 26 sept. 2012

TF4BRA1

7 / 24

Linux Commands Summary


cdrecord -v dev=/dev/cdrom -audio -pad *.wav oggenc --tracknum='track' track.cdda.wav -o 'track.ogg'

Make audio CD from all wavs in current dir (see also cdrdao) Make ogg file from wav file

disk space (See also FSlint)


ls -lSr Show files by size, biggest last Show top disk users in current dir. See also du -s * | sort -k1,1rn | head dutop du -hs /home/* | sort -k1,1h Sort paths by easy to interpret disk usage df -h Show free space on mounted filesystems df -i Show free inodes on mounted filesystems Show disks partitions sizes and types (run as fdisk -l root) rpm -q -a --qf '%10{SIZE}\t%{NAME}\n' | List all packages by installed size (Bytes) on sort -k1,1n rpm distros dpkg-query -W -f='${InstalledList all packages by installed size (KBytes) on Size;10}\t${Package}\n' | sort -k1,1n deb distros dd bs=1 seek=2TB if=/dev/null Create a large test file (taking no space). See of=ext3.test also truncate > file truncate data of file or create an empty file

monitoring/debugging
tail -f /var/log/messages strace -c ls >/dev/null strace -f -e open ls >/dev/null ls >/dev/null ltrace -f -e getenv ls >/dev/null lsof -p $$ lsof ~ tcpdump not port 22 ps -e -o pid,args --forest
ps -e -o pcpu | sed '/^ 0.0 /d' strace -f -e trace=write -e write=1,2

Monitor messages in a log file Summarise/profile system calls made by command List system calls made by command Monitor what's written to stdout and stderr List library calls made by command List paths that process id has open List processes that have specified path open Show network traffic except ssh. See also tcpdump_not_me List processes in a hierarchy

pcpu,cpu,nice,state,cputime,args --sort List processes by % cpu usage pr -TW$COLUMNS


ps -e -orss=,args= | sort -b -k1,1n | ps -C firefox-bin -L -o

List processes by mem (KB) usage. See also ps_mem.py List all threads for a particular process List elapsed wall time for particular process IDs

pid,tid,pcpu,state

ps -p 1,$$ -o etime= TF4BRA1

8 / 24

26 sept. 2012

Linux Commands Summary last reboot free -m watch -n.1 'cat /proc/interrupts' udevadm monitor Show system reboot history Show amount of (remaining) RAM (-m displays in MB) Watch changeable data continuously Monitor udev events to help configure rules

system information (see also sysinfo) ('#' means root access is required)
uname -a head -n1 /etc/issue cat /proc/partitions grep MemTotal /proc/meminfo grep "model name" /proc/cpuinfo lspci -tv lsusb -tv mount | column -t /proc/acpi/battery/BAT0/info #dmidecode -q | less #Power_On_Hours
smartctl -A /dev/sda | grep grep -F capacity:

Show kernel version and system architecture Show name and version of distribution Show all partitions registered on the system Show RAM total seen by the system Show CPU(s) info Show PCI info Show USB info List mounted filesystems on the system (and align output) Show state of cells in laptop battery Display SMBIOS/DMI information How long has this disk (system) been powered on in total Show info about disk sda Do a read speed test on disk sda Test for unreadable blocks on disk sda

#hdparm -i /dev/sda #hdparm -tT /dev/sda #badblocks -s /dev/sda

interactive (see also linux keyboard shortcuts)


readline screen mc gnuplot links xdg-open . Line editor used by bash, python, bc, gnuplot, ... Virtual terminals with detach capability, ... Powerful file manager that can browse rpm, tar, ftp, ssh, ... Interactive/scriptable graphing Web browser open a file or url with the registered desktop application

Part II
My previous reference for practical Linux commands was surprisingly popular with over 3.5 million hits in nearly 5 years. So I've decided to start compiling another list of somewhat more involved/esoteric commands. TF4BRA1 9 / 24 26 sept. 2012

Linux Commands Summary Examples marked with are valid/safe to paste without modification into a terminal, so you may want to keep a terminal window open while reading this so you can cut & paste.

Command
grep . /proc/sys/net/ipv4/* set | grep $USER $/environ
tr '\0' '\n' < /proc/$

Description List the contents of flag files Search current environment Display the startup environment for any process Display the $PATH one per line Check for the existence of a process (pid) Search paths and data with full context. Use n to iterate Output attributes for all directories leading to a file name

echo $PATH | tr : '\n' exists and can accept


kill -0 $$ && echo process signals find /etc -readable | xargs less -K -p'*ntp' -j $(($ {LINES:-25}/2))

namei -l ~/.ssh

Low impact admin


apt-get install "package" -o Acquire::http::Dl-Limit=42 \ #-o Acquire::Queuemode=access echo 'wget url' | at 01:00 apache2ctl configtest &&

Rate limit apt-get to 42KB/s Download url at 1AM to current dir

#apache2ctl graceful Restart apache if config is OK nice openssl speed sha1 Run a low priority command (openssl benchmark) chrt -i 0 openssl speed sha1 Run a low priority command (more effective than nice) -p $$
renice 19 -p $$; ionice -c3

Make shell (script) low priority. Use for non interactive tasks

Interactive monitoring
watch -t -n1 uptime htop -d 5 iotop #ps_mem.py | tail -n $(($
{LINES:-12}-2))" watch -d -n30 "nice

Clock with system load Better top (scrollable, tree view, lsof/strace integration, ...) What's doing I/O What's using RAM What's using the network. See also iptraf ping and traceroute combined

#iftop #mtr www.pixelbeat.org

Useful utilities
pv < /dev/zero > /dev/null wkhtml2pdf Progress Viewer for data copying from files and pipes Make a pdf of a web page

http://.../linux_commands.ht

TF4BRA1

10 / 24

26 sept. 2012

Linux Commands Summary


ml linux_commands.pdf

timeout 1 sleep 3

run a command with bounded time. See also timeout

Networking
python -m SimpleHTTPServer
openssl s_client -connect www.google.com:443 </dev/null 2>&0 | openssl x509 -dates -noout

Serve current directory tree at http://$HOSTNAME:8000/ Display the date range for a site's certs Display the server headers for a web site What's using port 80 Display a list of apache virtual hosts Edit remote file using local vim. Good for high latency links Import a gpg key from the web Add 20ms latency to loopback device (for testing) Remove latency added above

curl -I www.pixelbeat.org #lsof -i tcp:80 #httpd -S


vim scp://user@remote//path/to/f ile curl -s http://www.pixelbeat.org/pix elbeat.asc | gpg --import tc qdisc add dev lo root handle 1:0 netem delay 20msec

tc qdisc del dev lo root

Notification
echo "DISPLAY=$DISPLAY xmessage cooker" | at "NOW +30min" notify-send "subject" "message" echo "mail -s 'go home' P@draigBrady.com < /dev/null" | at 17:30 uuencode file name | mail -s subject P@draigBrady.com ansi2html.sh | mail -a "Content-Type: text/html" P@draigBrady.com

Popup reminder Display a gnome popup notification Email reminder Send a file via email Send/Generate HTML email

Better default settings (useful in your .bashrc)


#/var/log/messages {LINES:-12}-2)) #tcpdump -s0
seq 100 | tail -n $(($ tail -s.1 -f

Display file additions more responsively Display as many lines as possible without scrolling Capture full network packets

Useful functions/aliases (useful in your .bashrc)


md () { mkdir -p "$1" && cd TF4BRA1 Change to a new directory 11 / 24 26 sept. 2012

Linux Commands Summary


"$1"; } strerror() { python -c "import os; print os.strerror($1)"; } plot() { { echo 'plot "-"' "$@"; cat; } | gnuplot -persist; } hili() { e="$1"; shift; grep --col=always -Eih "$e|$" "$@"; }

Display the meaning of an errno Plot stdin. (e.g: seq 1000 | sed 's/.*/s(&)/' | bc -l | plot) highlight occurences of expr. (e.g: env | hili $USER)

alias hd='od -Ax -tx1z -v' Hexdump. (usage e.g.: hd /proc/self/cmdline | less) alias realpath='readlink -f' Canonicalize path. (usage e.g.: realpath ~/../$USER) "'$1"; }
ord() { printf "0x%x\n" chr() { printf $(printf '\\

shell version of the ord() function shell version of the chr() function

%03o\\n' "$1"); }

Multimedia
root orig.png
DISPLAY=:0.0 import -window convert -filter catrom

Take a (remote) screenshot Shrink to width, computer gen images or screenshots Extract audio from flash video to audiodump.wav Display info about multimedia file Capture video of an X display

-resize '600x>' orig.png

600px_wide.png mplayer -ao pcm -vo null -vc dummy /tmp/Flash* ffmpeg -i filename.avi

ffmpeg -f x11grab -s xga -r 25 -i :0 -sameq demo.mpg

DVD
for i in $(seq 9); do ffmpeg -i $i.avi -target pal-dvd $i.mpg; done dvdauthor -odvd -t -v "pal,4:3,720xfull" *.mpg;dvdauthor -odvd -T growisofs -dvd-compat -Z /dev/dvd -dvd-video dvd

Convert video to the correct encoding and aspect for DVD Build DVD file system. Use 16:9 for widescreen input Burn DVD file system to disc

Unicode
unicodedata as u; print
u.name(unichr(0x2028))" printf '\300\200' | iconv printf 'TF8\n' | LANG=C +' python -c "import

Lookup a unicode character

uconv -f utf8 -t utf8 -x nfc Normalize combining characters -futf8 -tutf8 >/dev/null Validate UTF-8

grep --color=always '[^ -~]\ Highlight non printable ASCII chars in UTF-8

TF4BRA1

12 / 24

26 sept. 2012

Linux Commands Summary fc-match -s "sans:lang=zh" List font match order for language and style

Development
gcc -march=native -E -v -</dev/null 2>&1|sed -n 's/.*-mar/-mar/p' for i in $(seq 4); do { [ $i = 1 ] && wget http://url.ie/6lko -qO-|| ./a.out; } | tee /dev/tty | gcc -xc - 2>/dev/null; done

Show autodetected gcc tuning params. See also gcccpuopt

Compile and execute C code from stdin Show all predefined macros Show all glibc feature macros Debug showing source code context in separate windows

cpp -dM /dev/null | cpp -dN | grep "#define


__USE_" gdb -tui echo "#include <features.h>"

udev
info -q path -n
udevadm info -a -p $(udevadm /dev/input/mouse0) udevadm test /sys/class/input/mouse0 udevadm control --reload#rules

List udev attributes of a device, for matching rules etc. See how udev rules are applied for a device Reload udev rules after modification

Extended Attributes (Note you may need to (re)mount with "acl" or "user_xattr" options)
getfacl . setfacl -m u:nobody:r . setfacl -x u:nobody .
setfacl --default -m group:users:rw- dir/ getcap file setcap cap_net_raw+ep your_gtk_prog

Show ACLs for file Allow a specific user to read file Delete a specific user's rights to file Set umask for a for a specific dir Show capabilities for a program Allow gtk program raw access to network Show SELinux context for file Set SELinux context for file (see also restorecon) Show all extended attributes (includes selinux,acls,...) Set arbitrary user attributes

stat -c%C .
chcon ... file

getfattr -m- -d . "bar" .


setfattr -n "user.foo" -v

BASH specific
tr 1 b
echo 123 | tee >(tr 1 a) |

Split data to 2 commands (using process substitution)

TF4BRA1

13 / 24

26 sept. 2012

Linux Commands Summary


meld local_file <(ssh host cat remote_file)

Compare a local and remote file (using process substitution)

Multicore
taskset -c 0 nproc -r0 -P$(nproc) -n10 md5sum
find -type f -print0 | xargs sort -m <(sort data1) <(sort data2) >data.sorted

Restrict a command to certain processors Process files in parallel over available processors Sort separate data files over 2 processors

Brief overview of Unix and Linux commands


Below is a listing of each of the Unix and Linux commands currently listed on Computer Hope and a brief explanation of what each of the commands do. This is a full listing which means not all the below commands will work with your distribution and may also not work because of your privileges. Clicking on any of the commands will display additional help and information about that command. Command Description
a2p ac alias ar arch arp as at awk basename bash bc bdiff bfs bg biff break bs bye

Creates a Perl script from an awk script. Prints statistics about users' connect time. Create a name for another command or long command string. Maintain portable archive or library. Display the architecture of the current host. Manipulate the system ARP cache. An assembler. Command scheduler. Awk script processing program. Deletes any specified prefix from a string. Command Bourne interpreter Calculator. Compare large files. Editor for large files. Continues a program running in the background. Enable and disable incoming mail notifications. Break out of while, for, foreach, or until loop. Battleship game. Alias often used for the exit command. 14 / 24 26 sept. 2012

TF4BRA1

Linux Commands Summary


cal calendar cancel cat cc cd chdir checkeq checknr chfn chgrp chkey chmod chown chsh cksum clear cls cmp col comm compress continue copy cp cpio crontab csh csplit ctags

Calendar. Display appointments and reminders. Cancels a print job. View or modify a file. C compiler. Change directory. Change directory. Language processors to assist in describing equations. Check nroff and troff files for any errors. Modify your own information or if super user or root modify another users information. Change a groups access to a file or directory. Change the secure RPC key pair. Change the permission of a file. Change the ownership of a file. Change login shell. Display and calculate a CRC for files. Clears screen. Alias often used to clear a screen. Compare files. Reverse line-feeds filter. Compare files and select or reject lines that are common. Compress files on a computer. Break out of while, for, foreach, or until loop. Copy files. Copy files. Creates archived CPIO files. Create and list files that you wish to run on a regular schedule. Execute the C shell command interpreter Split files based on context. Create a tag file for use with ex and vi.

TF4BRA1

15 / 24

26 sept. 2012

Linux Commands Summary


cu curl cut date dc dd df deroff dhclient diff dig dircmp dirname dmesg dos2unix dpost du echo ed edit egrep elm emacs enable env eqn ex exit expand expr fc

Calls or connects to another Unix system, terminal or non-Unix system. Transfer a URL. Cut out selected fields of each line of a file. Tells you the date and time in Unix. An arbitrary precision arithmetic package. Convert and copy a file. Display the available disk space for each mount. Removes nroff/troff, tbl, and eqn constructs. Dynamic Host Configuration Protocol Client. Displays two files and prints the lines that are different. DNS lookup utility. Lists the different files when comparing directories. Deliver portions of path names. Print or control the kernel ring buffer. Converts text files between DOS and Unix formats. Translates files created by troff into PostScript. Tells you how much space a file occupies. Displays text after echo to the terminal. Line oriented file editor. Text editor. Search a file for a pattern using full regular expressions. Program command used to send and receive e-mail. Text editor. Enables and disables LP printers. Displays environment variables. Language processors to assist in describing equations. Line-editor mode of the vi text editor. Exit from a program, shell or log you out of a Unix network. Expand copies of file s. Evaluate arguments as an expression. The FC utility lists or edits and re-executes, commands previously entered to an 16 / 24 26 sept. 2012

TF4BRA1

Linux Commands Summary interactive sh.


fg fgrep file find findsmb finger fmt fold for

Continues a stopped job by running it in the foreground Search a file for a fixed-character string. Tells you if the object you are looking at is a file or if it is a directory. Finds one or more files assuming that you know their approximate filenames. List info about machines that respond to SMB name queries on a subnet. Lists information about the user. Simple text formatters. Filter for folding lines. Shell built-in functions to repeatedly execute action(s) for a selected number of times. Shell built-in functions to repeatedly execute action(s) for a selected number of times. Display amount of free and used memory in the system Converts text files between DOS and Unix formats. Check and repair a Linux file system. Enables ftp access to another terminal. Display discretionary file information. The gprof utility produces an execution profile of a program. Finds text within a file. Creates a new group account. Enables a super user or root to remove a group. Enables a super user or root to modify a group. Expand compressed files. A programmers text editor. A programmers text editor. Compress files. Stop the computer. Remove internal hash table. Display the hash stats. Displays the first ten lines of a file, unless otherwise stated. 17 / 24 26 sept. 2012

foreach free fromdos fsck ftp getfacl gprof grep groupadd groupdel groupmod gunzip gview gvim gzip halt hash hashstat head

TF4BRA1

Linux Commands Summary


help history host hostid hostname id ifconfig ifdown ifup init ip isalist jobs join keylogin kill ksh ld ldd less lex link ln lo locate login logname logout lp lpadmin lpc

If computer has online help documentation installed this command will display it. Display the history of commands typed. DNS lookup utility. Prints the numeric identifier for the current host. Set or print name of current host system. Shows you the numeric user and group ID on BSD. Sets up network interfaces. Take a network interface down. Bring a network interface up. Process control initialization. Show and manipulate routing, devices, policy routing and tunnels. Display the native instruction sets executable on this platform. List the jobs currently running in the background. Joins command forms together. Decrypt the user's secret key. Cancels a job. Korn shell command interpreter. Link-editor for object files. List dynamic dependencies of executable files or shared objects. Opposite of the more command. Generate programs for lexical tasks. Calls the link function to create a link to a file. Creates a link to a file. Allows you to exit from a program, shell or log you out of a Unix network. List files in databases that match a pattern. Signs into a new system. Returns users login name. Logs out of a system. Prints a file on System V systems. Configure the LP print service. Line printer control program. 18 / 24 26 sept. 2012

TF4BRA1

Linux Commands Summary


lpq lpr lprm lpstat ls mach mail mailcompa t mailx make man mesg mii-tool mkdir mkfs more mount mt mv nc neqn netstat newalias newform newgrp nice niscat nischmod nischown nischttl

Lists the status of all the available printers. Submits print requests. Removes print requests from the print queue. Lists status of the LP print services. Lists the contents of a directory. Display the processor of the current host. One of the ways that allows you to read/send E-Mail. Provide SunOS 4.x compatibility for the Solaris mailbox format. Mail interactive message processing system. Executes a list of shell commands associated with each target. Display a manual of a command. Control if non-root users can send text messages to you. View, manipulate media-independent interface status. Create a directory. Build a Linux file system, usually a hard disk partition. Displays text one screen at a time. Creates a file systems and remote resources. Magnetic tape control. Renames a file or moves it from one directory to another directory. TCP/IP swiss army knife. Language processors to assist in describing equations. Shows network status. Install new elm aliases for user or system. Change the format of a text file. Log into a new group. Invokes a command with an altered scheduling priority. Display NIS+ tables and objects. Change access rights on a NIS+ object. Change the owner of a NIS+ object. Change the time to live value of a NIS+ object.

TF4BRA1

19 / 24

26 sept. 2012

Linux Commands Summary


nisdefaul ts nisgrep nismatch nispasswd nistbladm nmap nohup nroff nslookup on onintr optisa pack pagesize passwd paste pax pcat perl pg pgrep pico pine ping pkill poweroff pr priocntl

Display NIS+ default values. Utilities for searching NIS+ tables. Utilities for searching NIS+ tables. Change NIS+ password information. NIS+ table administration command. Network exploration tool and security port scanner. Runs a command even if the session is disconnected or the user logs out. Formats documents for display or line-printer. Queries a name server for a host or domain lookup. Execute a command on a remote system, but with the local environment. Shell built-in functions to respond to (hardware) signals. Determine which variant instruction set is optimal to use. Shrinks file into a compressed file. Display the size of a page of memory in bytes, as returned by getpagesize. Allows you to change your password. Merge corresponding or subsequent lines of files. Read/write and writes lists of the members of archive files and copy directory hierarchies. Compresses file. Perl is a programming language optimized for scanning arbitrary text files, extracting information from those text files. Files perusal filters for CRTs. Examine the active processes on the system and reports the process IDs of the processes Simple and very easy to use text editor in the style of the Pine Composer. Command line program for Internet News and Email. Sends ICMP ECHO_REQUEST packets to network hosts. Examine the active processes on the system and reports the process IDs of the processes Stop the computer. Formats a file to make it look better when printed. Display's or set scheduling parameters of specified process(es) 20 / 24 26 sept. 2012

TF4BRA1

Linux Commands Summary


printf ps pvs pwd quit rcp reboot red rehash remsh repeat replace rgview rgvim rlogin rm rmail rmdir rn route rpcinfo rsh rsync rview rvim s2p sag sar screen script

Write formatted output. Reports the process status. Display the internal version information of dynamic objects within an ELF file. Print the current working directory. Allows you to exit from a program, shell or log you out of a Unix network. Copies files from one computer to another computer. Stop the computer. Line oriented file editor. Recomputes the internal hash table of the contents of directories listed in the path. Runs a command on another computer. Shell built-in functions to repeatedly execute action(s) for a selected number of times. A string-replacement utility. A programmers text editor. A programmers text editor. Establish a remote connection from your terminal to a remote machine. Deletes a file without confirmation (by default). One of the ways that allows you to read/send E-Mail. Deletes a directory. Reads newsgroups. Show and manipulate the IP routing table. Report RPC information. Runs a command on another computer. Faster, flexible replacement for rcp. A programmers text editor. A programmers text editor. Convert a sed script into a Perl script. Graphically displays the system activity data stored in a binary data file by a previous sar run. Displays the activity for the CPU. Screen manager with VT100/ANSI terminal emulation. Records everything printed on your screen. 21 / 24 26 sept. 2012

TF4BRA1

Linux Commands Summary


sdiff sed sendmail set setenv setfacl settime sftp sh shred shutdown sleep slogin smbclient sort spell split stat stop strip stty su sysinfo sysklogd tabs tail talk tac tar tbl

Compares two files, side-by-side. Allows you to use pre-recorded commands to make changes to text. Sends mail over the Internet. Set the value of an environment variable. Set the value of an environment variable. Modify the Access Control List (ACL) for a file or files. Change file access and modification time. Secure file transfer program. Runs or processes jobs through the Bourne shell. Delete a file securely, first overwriting it to hide its contents. Turn off the computer immediately or at a specified time. Waits a x amount of seconds. OpenSSH SSH client (remote login program). An ftp-like client to access SMB/CIFS resources on servers. Sorts the lines in a text file. Looks through a text file and reports any words that it finds in the text file that are not in the dictionary. Split a file into pieces. Display file or filesystem status. Control process execution. Discard symbols from object files. Sets options for your terminal. Become super user or another user. Get and set system information strings. Linux system logging utilities. Set tabs on a terminal. Delivers the last part of the file. Talk with other logged in users. Concatenate and print files in reverse. Create tape archives and add or extract files. Preprocessor for formatting tables for nroff or troff.

TF4BRA1

22 / 24

26 sept. 2012

Linux Commands Summary


tcopy tcpdump tee telinit telnet test time timex todos top touch tput tr tracerout e troff tty ul umask unalias unhash uname uncompres s uniq unlink unmount unpack untar until unzip useradd

Copy a magnetic tape. Dump traffic on a network. Read from an input and write to a standard output or file. Process control initialization. Uses the telnet protocol to connect to another remote computer. Check file types and compare values. Used to time a simple command. The timex command times a command; reports process data and system activity. Converts text files between DOS and Unix formats. Display Linux tasks. Change file access and modification time. Initialize a terminal or query terminfo database. Translate characters. Print the route packets take to network host. Typeset or format documents. Print the file name of the terminal connected to standard input. Reads the named filenames or terminal and does underlining. Get or set the file mode creation mask. Remove an alias. Remove internal hash table. Print name of current system. Uncompressed compressed files. Report or filter out repeated lines in a file. Call the unlink function to remove the specified file. Disconnects a file systems and remote resources. Expands a compressed file. Create tape archives and add or extract files. Execute a set of actions while/until conditions are evaluated TRUE. List, test and extract compressed files in a ZIP archive. Create a new user or updates default new user information.

TF4BRA1

23 / 24

26 sept. 2012

Linux Commands Summary


userdel usermod vacation vedit vgrind vi vim view w wait wc whereis while which who whoami whois write X xfd xlsfonts xset xterm xrdb yacc yes yppasswd zcat zip

Remove a users account. Modify a users account. Reply to mail automatically. Screen-oriented (visual) display editor based on ex. Grind nice program listings Screen-oriented (visual) display editor based on ex. A programmers text editor. A programmers text editor. Show who is logged on and what they are doing. Await process completion. Displays a count of lines, words, and characters in a file Locate a binary, source, and manual page files for a command. Repetitively execute a set of actions while/until conditions are evaluated TRUE. Locate a command. Displays who is on the system. Print effective userid. Internet user name directory service. Send a message to another user. Execute the X windows system. Display all the characters in an X font. Server font list displayer for X. User preference utility for X. Terminal emulator for X. X server resource database utility. Short for yet another compiler-compiler, yacc is a compiler. Repeatedly output a line with all specified STRING(s), or 'y'. Changes network password in the NIS database. Compress files. Compression and file packaging utility.

TF4BRA1

24 / 24

26 sept. 2012

You might also like