![]() |
Linux/Unix Commands File Commands
Text Processing/Parsing Commands
Archive Commands
Network Commands
Programming Commands
Binary Commands
Examples
Remove a file with a leading '-' character
[user@host user]$ rm -- -file
Remove the '\r' (carriage return) from DOS files
[user@host user]$ cat file | tr -d '\015' > file.$$ && mv -i file.$$ file
How to find 'text' in a group of files
[user@host user]$ find . -exec grep text {} \; -print 2>/dev/null
Find files with an executable bit set
[user@host user]$ find . -perm +111 ! -type d -print 2>/dev/null
Find files modified in the last two minutes on a single filesystem
[user@host user]$ find . -xdev -mmin -2 -print
Compute the amount of disk space used and order from greatest to least
[user@host user]$ du -sk * | sort -rn
Search for lines beginning with 'open' and containing either bash, login or profile
[user@host user]$ cat file | grep ^open | egrep '(bash|login|profile)'
Determine how many unique shells are used in /etc/passwd file
[user@host user]$ cat /etc/passwd | cut -d: -f 7 | sort | uniq
[user@host user]$ cat /etc/passwd | awk -F: '{print $7}' | sort | uniq
Create an archive
[user@host user]$ tar cf directory.tar directory | gzip -9 > directory.tar.gz
[user@host user]$ tar czf directory.tar.gz directory
List an archive's table of contents
[user@host user]$ gzip -dc directory.tar.gz | tar tf -
[user@host user]$ tar tzf directory.tar.gz
Extract an archive
[user@host user]$ gzip -dc directory.tar.gz | tar xvf -
[user@host user]$ tar xzvf directory.tar.gz
Move a directory from one filesystem to another
[user@host user]$ tar cf - directory | ( cd /filesystem2 ; tar xvpf - )
List the kernel routing table
[user@host user]$ netstat -rn
Determine somefile's file type
[user@host user]$ file somefile
Trace program's system calls and signals capturing all output in program.out
[user@host user]$ strace program &> program.out
Get the ASCII character or backslash escape characters of file
[user@host user]$ od -t c file
Hard reset the terminal (for when you accidentally cat a binary file)
[user@host user]$ echo ^O # type Ctl-v Ctl-o
Last updated |
|||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||