10.000 tips collections page

The biggest collection of Linux and other tips on the planet.
You are using contents on this page completelly on your own risk.
Authors will take no respone for any possible damage caused.




| alias | awk
| bg
| cal | cat | cd | chmod | clear | cp | cut
| date | dhclient | do | done
| echo | egrep | else | exit | expand | export | expr
| fg | fgrep | fi | file | find | finger | fmt | for
| gnome-control-center | gnome-sound-properties | gnome-system-monitor
| grep | gtv | gunzip | gzip
| head
| if | ifconfig | info | init
| jobs | join
| kcontrol | kill | killall | kmix | konqueror | kpm
| less | let | ln | locate | logout | ls
| man | mesg | mkdir | mkpasswd | more | mount | mv
| nautilus | neat | neat-tui | nice | nl | noatun
| od
| passwd | paste | pr | ps | pstree | pwd
| read | renice | rm | rmdir | rpm
| sed | shift | sort | source | startix | stat | strings | switchdesk
| system-config-display | system-config-network | system-config-network-tui
| system-config-printer | system-config-soundcard
| tac | tail | talk | tar | tee | telinit | test | then | top | tr | true | type
| umount | unexpand | updatedb
| vi | vlock
| wall | wc | webmin | whereis | which | while | who | whoami | write
| X | xlock | xmms
| yast | zcat


alias _____________________ define or display aliases

Warning: aliases are not exportable variables so they can not be
inherited must be stored in configurable files, that are executed for
each new shell, instance like .bashrc or they must be defined inside
each script.


Print out all aliases that are available for the current shell:


Hexdump example usage e.g.: hd /etc/group

alias hd='od -tx1z -v'

Quick dir listing

alias ll='ls -lah --color=auto'

Canonicalize path. (usage e.g.: . realpath ~/../$USER)

alias realpath='readlink -f'

Unset alias

unalias alias-name

Set some usefull aliases:

alias cp='cp -i'
alias l.='ls -d .* --color=tty'
alias ll='ls -l --color=tty'
alias ls='ls --color=tty'
alias mv='mv -i'
alias rm='rm -i'
alias lsh='ls -a | grep "^\."'
alias kde='echo "exec startkde" > /root/.xinitrc ; startx'
alias gnome='echo "exec gnome-session" > /root/.xinitrc ; startx'

Aliases for DOS commands

alias md="mkdir -p" # make directory
alias rd="rmdir -p" # remove directory
alias del='rm -i' # delete file
alias copy='cp -i' # copy
alias ren='mv' # move / rename

for detailed options see:

man alias


awk _____________________ pattern scanning and processing language

What does some strange unix command names stand for ?

awk = "Aho Weinberger and Kernighan"

COMPLETE awk doc


kill all processes containing keyword

kill $(ps fa | grep 'mp3' | awk '{print $2}')

use awk as grep

awk '/ls/' /etc/passwd


n=$(awk 'BEGIN { for (i = 1; i <= 7; i++) \
print int(40 * rand()) }'|sort -n);echo $n

Number count of lines containing the word "Mat" in a file:

cat textfile | awk '/Mat/ {nlines = nlines + 1} END {print nlines}'

To Print fields (columns) in reverse order:

awk '{ for (i = NF; i > 0; --i) print $i }' textfile

Print only lines longer than 50 characters:

awk 'length > 50' textfile

Print the first field of each line and its lenght

awk '{print $1," ",length($1)}' /etc/passwd

get only file names form a current dir

ls -l | grep -v '^d' | awk '{ print $9 }'

Remove all even lines from example.txt

cat example.txt | awk 'NR%2==1'

View the first column of a line

echo a b c | awk '{print $1}'

View the first and third column of a line

echo a b c | awk '{print $1,$3}'

Print lines longer than 72 characters:

awk 'length > 7' file1

Print first two fields in opposite order:

awk '{ print $2, $1 }' /etc/passwd

Print last word of each line from specified file1

awk '{print $NF}' /tmp/file1

Print one field before last

uptime|awk '{print $(NF-1)}'

Print total sizes of ordinary files in all subdirs:

ls -lR|grep ^- |awk '{ sum += $5 }; END { print sum }'

Print all lines between start/stop pairs:

awk '/start/, /stop/' /etc/sysconfig/hwconf

Show only lines from a file1 that are less, longer or 80 characters long

awk "length ==80" file1
awk "length <80" file1
awk "length >80" file1

Separate multiline fields with --
Print out only fields containing keyword

clear;awk '{ RS = "--" } /zipinfo / ' examples.db

Print all lines where field three matches a condition.
But do not print whole lines, just print second field from those lines.

awk '$3 == "ext3" { print $2 }' /etc/fstab

Use a different Field separator

cat /etc/group|awk -F ':' '{print $1}'

Split file on repeating keyword CHAPTER and nuber every created file:

awk 'BEGIN{RS="CHAPTER";OFS="\n"}{ print > "myfile"NR}' testfile.txt

Summarize all numbers in first column of file1

gawk '{ sum += $1 }; END { print sum }' file1

Print all system users

gawk -F: '{ print $1 }' /etc/passwd

Print all system users and sort them

cat /etc/passwd|gawk 'BEGIN { FS = ":" };{ print $1 | "sort" }'

Print number of lines in a file

gawk '{ nlines++ };{ print nlines }' /etc/passwd

Number each line in a file

awk '{ print NR, $0 }' /etc/passwd

Count lines in a file.

awk 'END { print NR }' my_data_file

Print all lines whose first field (column) is different from the
previous one:

awk '$1 != prev { print; prev = $1 }' textfile

Print number of characters for each line in a file

awk '{print length($0)}' examples

Displaying all users with UID of 0

awk -F: '{if($3 == 0) print $1}' /etc/passwd

Removing blank lines with awk

awk 'NF>0' < text_file

print configured ip addresses

ifconfig | awk '/inet/{print $2}' | awk -F: '{print $2}'

This awk program prints the even numbered lines in the my_data_file file.

awk 'NR % 2 == 0' my_data_file

This awk program prints the odd numbered lines in the my_data_file file.

awk 'NR % 2 == 1' my_data_file

Prints the total number of kilobytes used by files.

ls -lg files |
awk '{ x += $5 } END { print "total K-bytes: " (x + 1023)/1024 }'

To delete blank lines from a text file

awk 'NF > 0' my_text_file

Prints the length of the longest line in `my_data_file'. Input processed
through "expand" to change tabs to spaces.

expand my_data_file | awk '{ if (x < length()) x = length()} \
END { print "maximum line length is " x }'

To have exclusive listing of files only (no sub-dirs):

ls -al | awk '$0!~/^d/ {print $9}'

for detailed options see:

man awk


bg _____________________ run jobs in the background

To push a running process to the background
freeze it first: ctrl+z
this will produce %1 job identifier

bg %1

for detailed options see:

man bg


cal _____________________ display a calendar

Dispaly calender for a current month


Dispaly calender for a current year

cal 2008

Display calendar dates for the whole years

cal -y

Display julian dates (number of days from 1 to 365)

cal -j

Display a calendar

cal -1

Display a calendar with one month before and one in the future

cal -3

Display a calendar for a particular month year

cal 9 2008

for detailed options see:

man cal


cp _____________________ copy files and directories

Create fast backup of a file

cp /etc/fstab{,.bak}

Copy a file to another location

cp /tmp/f1 /var/tmp/f2

Make an archive copy of entire directory:

cp -a /opt /tmp

To create a zero-length file, using cp:

cp /dev/null /tmp/file

Copy a directory within the current work directory and preserve attributes

cp -a -p /tmp/dir1 .

Backing up a directory preserving ownerships, permissions and
links, to another partition to hard disk, do:

cp -a /dir-to-backup -or- cp -dpR /dir-to-backup

Copy all files of a directory within the current work directory

cp dir/* .

for detailed options see:

man cp


cat _____________________ concatenate and print files

catenate is an obscure word meaning "to connect in a series"


Number row of a file

cat -n file1

Join splitted files into one single binary or txt

cat xaa xab xac >prog.bin -or- cat x* >prog.bin

To create a zero-length file, using cat:

cat /dev/null > file

Get all contetnts from a file

cat /tmp/file1

Display a file

at ch1

Combine files

cat ch1 ch2 ch3 > all

Append to a file

cat note5 >> notes

Create file at terminal. To exit, enter EOF (Ctrl-D).

cat > temp1

Create file at terminal. To exit, enter STOP.

cat > temp2 << STOP

The following prints ^I for all the occurrences of tab character in file1

cat -t file1

To suppress error messages about files that do not exist, use:

cat -s file1 file2 file3 > file

To view non-printable characters in file2, use:

cat -v file2

general syntax to manipulate a text of a file, and write result to a new file

cat file1 | command( sed, grep, awk, grep, etc...) > result.txt

see all characters in a file (also strange ones and from dos ...)

cat -vet textfile

join contetnt from files with command output
Command below will show contetnts of header_file first, then result of w
command and after that contetnts of footer_file

w|cat header_file - footer_file

for detailed options see:

man cat


cd _____________________ change the working directory

Go to home directory

cd ~

Go to previous directory

cd -

Go to dir, execute command and return to current dir

(cd dir && command)

Change working directory and if successfull, execute listing

cd /tmp && ls

Enter to directory '/ home'

cd /home

Go back one level

cd ..

Go back two levels

cd ../..

for detailed options see:

man cd






chmod _____________________ change file access permissions

There are three permissions for files and directories.
Set permissions:

reading (r)
write (w)
execute (x)
users (u)
group (g)
others (o)
chmod ugo+rwx directory1

Remove permits reading (r), write (w) and (x) access to users group
(g) and others (o)

chmod go-rwx directory1

There are aditiona three special parmissions available for files and directories:

SGID 2000
SUID 4000

A classic way to change permissions for user : read, write, execute
for group : read, execute
for others: read

chmod 754 /tmp/myprog

But what you really performed is:

chmod 0754 /tmp/myprog

Access permissions table
Permissions has a slightly different but significant meaning
on files or directories.

     | mode | notation  | file:             | directory                       |
     | 1000 |---------T | save txt attr:    | link permissions: allow user to |
     |      |           |                   | operate on his own files only   |
     | 2000 |------S--- | set Group ID:     | set Group ID: usable for samba. |
     |      |           |                   | file sharing among users.       |
     | 4000 |           | set User ID:      | set User ID:                    |
     |      |---S------ | usable for suid   |                                 |
     |      |           | programs (passwd) |                                 |
     |    1 |   --x     | execute           | browse                          |
     |    2 |   r--     | read.             | list contents                   |
     |    4 |   -w-     | write.            | create file                     |

Add execute-by-user permission to file:

chmod u+x /tmp/testprog

Either of the following will assign read/write/execute permission by owner
r/x permission by group, and x-only permission by others to file:

chmod 751 /tmp/testprog chmod u=rwx,g=rx,o=x file

Any one of the following will assign r-only permission to file for everyone

chmod =r /tmp/testprog
chmod 444 /tmp/testprog
chmod a-wx,a+r /tmp/testprog

The following makes the executable setuid, assigns read/write/execute
permission by owner, and assigns r/x permission by group and others

chmod 4755 /tmp/testprog

Deny write permission to others:

chmod o-w file

Make a file executable by everybody:

chmod a+x file

Assign read and execute permission to everybody, and set the set-user-ID bit:

chmod a=rx,u+s file

Assign read and write permission to the file owner, and read permission to everybody else:

chmod u=rw,go=r file

Set SUID bit on a binary file - the user that running that file
gets same privileges as owner

chmod u+s /bin/file1

Disable SUID bit on a binary file

chmod u-s /bin/file1

Set SGID bit on a directory - similar to SUID but for directory

chmod g+s /home/public

Disable SGID bit on a directory

chmod g-s /home/public

Set STIKY bit on a directory - allows files deletion only to legitimate owners

chmod o+t /home/public

Disable STIKY bit on a directory

chmod o-t /home/public

for detailed options see:

man chmod


clear _____________________ clear the terminal screen

clear screen if possible

clear -or- ctrl+l


cut _____________________ remove sections from each line of files

Get specified columns from txt files

cut -d " " -f 1,3 /tmp/tt.txt

Extract groups from /etc/group file

cut -d: -f1 /etc/group

Find out who is logged on, but list only login names:

w | cut -d" " -f1

Cut characters in the 3rd column of file1,
and paste them back as the first column in the same file:

cut -c3 file1 | paste - file1

Convert file source containing lines of arbitrary length into two files
where file1 contains the first 500 bytes, 2nd file the rest.

cut -b 1-500 -n source > file1
cut -b 500- -n source > file2

for detailed options see:

man cut


date _____________________ print or set the system date and time

Show system date and time:


Show UTC time:

date -u

Set date and tim in more human readable way:

date -s "Sat Nov 3 18:59:04 2008"

Convert number of seconds since the epoch to a date:

date --date '1970-01-01 UTC 1234567890 seconds'

What day does xmas fall on, this year:

date --date='20 Oct' +%A

What date is it this thursday:

date -d thu

Set system date and time:

date 072315302007 # mmddHHMMyyyy

To set the system clock forward by two minutes:

date --set='+2 minutes'

What time is it on West coast of US (use tzselect to find TZ):

TZ=':America/Los_Angeles' date

Print custom formatted date:

date +%m-%d-%Y

To print the date of the day before yesterday:

date --date='2 days ago'

To print the date of the day three months and one day hence:

date --date='3 months 1 day'

To print the day of year of Christmas in the current year:

date --date='25 Dec' +%j

Display date of the current or next Wednesday:

date -d Wed

Give me file creation date:.

date -r /tmp/file1

Show yesterday's date:

echo $(date +%Y-%m-%d -d '-1 day')

for detailed options see:

man date

To print a date without the leading zero for one-digit
days of the month, you can use the (GNU extension)
`-' flag to suppress the padding altogether:

date -d 1may '+%B %-d

To print the current date and time in the format required
by many non-GNU ver.s of `date' when setting the system clock:

date +%m%d%H%M%Y.%S


dhclient _____________________ Dynamic Host Configuration Protocol Client

for details see:

man dhclient

Active interface 'eth0' in dhcp mode

dhclient eth0


do _____________________ if loop/case construct keyword

see: while, until



done _____________________ end of do loop

For detailed options see:

man setleds

Put this to /etc/rc.local to turn nuLock on:

for tty in $TTY; do
setleds -D +num < $tty

switch on all lights

setleds +num/ +caps/ +scroll &> /dev/null


echo _____________________ display a line of text

For detailed options see:

man echo

To clear console of gibberish (eg. after cat of a tar.gz file)
go to another virtual console and type in:

echo -e '\017' > /dev/tty1

Print many variable fields in a single line:

listing=$(ls -la /)
echo $listing

Print values from variable "as is"

listing=$(ls -la /);echo "$listing"

Base conver. (hex to dec) ((shell arithmetic expansion))

echo $((0x2dec))

Base math calcualtions

echo $((10+20))

Create an empty file using echo

echo > /tmp/new_file1



Print a short beep

echo -e "\a"

Start printing on position "two tabs" from start of the line

echo -en "\t \t"

Make cursor invisible

echo -en "\033[?25l"

Make cursor visible again

echo -en "\033[?12l\033[?25h"

Switch terminal to DRAW mode

echo -en "\033(0"

Switch terminal back to WRITE mode

echo -en "\033(B"

Mark text

echo -en "\033[7m"

Unmark text

echo -en "\033[27m"

Reset screen

echo -en "\033c"

Simple counter with suppressing newlines

for NUM in $(seq 1 100)
echo -e "\r $NUM \c"
usleep 100000

Painting text

echo -e "\033[44;37;5m ME \033[0m COOL"

Clear screen but preserver prompt position

echo -e "\033[2J"

Clear all keyboard LEDs

echo -e "\033[0q"

Set "Scroll Lock" LED

echo -e "\033[1q"

Set "Num Lock" LED

echo -e "\033[2q"

Set Caps Lock LED

echo -e "\033[3q"


echo -en "\x07"


0 reset all attributes to their defaults
1 set bold
2 set half-bright (simulated with color on a color display)
4 set underscore (simulated with color on a color display)
5 set blink
7 set reverse video
22 set normal intensity
24 underline off
25 blink off
27 reverse video off
30 set black foreground
31 set red foreground
32 set green foreground
33 set brown foreground
34 set blue foreground
35 set magenta foreground
36 set cyan foreground
37 set white foreground
38 set underscore on, set default foreground color
39 set underscore off, set default foreground color
40 set black background
41 set red background
42 set green background
43 set brown background
44 set blue background
45 set magenta background
46 set cyan background
47 set white background
49 set default background color


egrep _____________________ print lines matching a pattern

For detailed options see:

man egrep

egrep = "Extended GREP"

egrep uses fancier regular expressions than grep.Many people
use egrep all the time, since it has some more sophisticated
internal algorithms than grep or fgrep, and is usually the
fastest of the three programs.
Similar to grep -e

Search for occurrences of IP or GW in files inside current dir

egrep '(IP|GW)' *

Find and print strings such as old.doc or new.doc in files and include their line numbers:

egrep -n '(old|new)\.doc' files

Search for multiple patterns within the same file

egrep "patterna|patternb" file1

Show only text files inside current dir and exclude binaries

file * | egrep 'script|text' | awk -F: '{print $1}'


else _____________________ conditional operator

see: if



expand _____________________ convert tabs to spaces

For detailed options see:

man expand

Create file with all spaces instead of tabs

expand all-tabbed.tx > all-spaced.txt


export _____________________ set the export attribute for variables

For detailed options see:

man export

The purpose of this tool is to set variable values available to all subshells.


show all exported variables


Export PWD and HOME variables:

export PWD HOME

Set and export the PATH variable:

export PATH=/local/bin:$PATH

Save and restore all exported variables:

export -p > temp-fileunset a lot of variables... processing. temp-file

Enable displying X programs form another computer

setenv DISPLAY localname:0
export DISPLAY localname:0

If you are behind a proxy and must authenticate against it to access the
internet, then use the following command:

export http_proxy="http://usr:passwd@proxy.testcompany.com:port/"


expr _____________________ evaluate expressions

For detailed options see:

man expr

Add 3 to the shell variable b:

b=`expr $b + 3`

Simple math

echo $(expr 10 + 1)

Return the number of characters in $VAR:

expr $VAR : '.*'

Division is executed before adition:

expr 5 + 15 / 3

Addition inside braces happens first

expr \( 10 + 10 \) / 2

Add 1 to variable i. This is how variables are incremented in shell scripts:

i=`expr $i + 1`

Print 1 (true) if variable a is the string "hello":

expr $a = hello

Print 1 (true) if b plus 5 equals 20 or more:

expr $i + 5 \>= 20

Start at 5th character and prind two more letters of the word longword:

expr substr longword 5 3

In the examples that follow, variable p is the string
This command prints the number of characters in i:

expr $i : '.*'

Match all characters and print them:

expr $i : '\(.*\)'

Match the lowercase letter at the beginning of i:

expr $i : '\([a-z] *\)'

Truncate $i if it contains 4 or more characters; if not, just print $i.

expr $x : '\(....\)' \| $i

In a shell script, rename files to their first five letters:

mv $i `expr $i : '\(....\)' \| $i`


exit _____________________ cause normal process termination

For detailed options see:

man exit

Exit with a true value:

exit 0

Exit with a false value:

exit 1

Some error codes:

A file to be executed was found, but it was not an executable utility: 126
A utility to be executed was not found: 127
A command was interrupted by a signal: 128


fg _____________________ run jobs in the foreground

For detailed options see:

man fg

Call a job that is suspended or is running in background to the foreground

ls -lahR / &
fg %1


gnome-system-monitor _____________________ Simple process monitor

task manager for gnome, supports process management, load overviev,
disk usage status


top like graphical application. To start it and manipulate processes:

(use mouse right click to access possible options on processes)

little bug if gnome-system-monitor does not start:

killall -9 dbus-daemon dbus-launch


fgrep _____________________ print lines matching a pattern

For detailed options see:

man fgrep

fgrep = "Fixed GREP".

fgrep searches for fixed strings only. The "f" does not stand
for "fast"; in fact, "fgrep foobar *.c" is usually slower than
"egrep". Fgrep is useful when searching a file for a larger
number of strings than egrep can handle.

Print lines in file1 that contain souble spaces:

fgrep ' ' file1

Print lines from the file2 that contain the words from the file1:

fgrep -f file1 file2


fi _____________________ end of if-loop/condition construct

see: if



file _____________________ Figure out what is in an archive file

For detailed options see:

man file

Show all file types inside some directory

file /usr/bin/*

Show a file type for a specific file

file /bin/ls

Determine whether an argument is a binary executable file:

file "$1" | grep -Fq executable &&
printf "%s is executable.\n" "$1"

Some combined examples to get info on devices or files

file file.c file /dev/{wd0a,hda}
file -s /dev/wd0{b,d}
file -s /dev/hda{,1,2,3,4,5,6,7,8,9,10}
file -i file.c file /dev/{wd0a,hda}


find _____________________ search for files in a directory hierarchy

For detailed options see:

man find

Finding files exceeding specified size (in 512-byte blocks)

find / -size +10000

Find the 100 biggest files on your system

find / -type f -ls |awk '{print $7,$11}'|sort -n|tail -100

perform search of files with keyword and perform long listing

find /etc/ -name "*pass*" -ls

Make archive of subset of dir/ and below

find dir/ -name '*.txt' | tar c --files-from=- | bzip2 > dir_txt.tar.bz2

Make copy of subset of dir/ and below

find dir/ -name '*.txt' | xargs cp -a --target-directory=dir_txt/ --parents

Process each item with multiple commands - in while loop

find -maxdepth 1 -type d | while read dir; do echo ; echo cmd2; done

Search all regular files for 'string' in this dir

find -maxdepth 1 -type f | xargs grep -F 'string'

Search 'expr' in this dir and below. See also findrepo

find -name '*.[ch]' | xargs grep -E 'expr'

Find dirs not accessible by all (useful for web site)

find -type d ! -perm -111

Find files not readable by all (useful for web site)

find -type f ! -perm -444

Find all files with STICKY bit, SUID, GID parameters

find / -type f -perm 1000
find / -type f -perm 4000
find / -type f -perm 2000

View all files on the system with SUID configured

find / -perm -u+s

Find all your writable directories

find / -perm -0777 -type d

Search all regular files for 'string' in this dir and below

find -type f -print0 | xargs -r0 grep -F 'string'

Search the two directories /example1 and /example2 for files containing the string New word and print the names of the files:

find /example1 /example2 -exec grep -l 'New word' {} \;

Remove all files named test.doc or *.txt that have not been accessed for seven days:

find /tmp \( -name test.doc -o -name '*.txt' \) -atime +7 -exec rm {} \;

Copy the entire file system to a disk mounted on /archive, avoiding the recursive copy problem.

cd /; find . -path ./archive -prune -o -print | cpio -pxdm /archive

Copy the root disk to a disk mounted on /archive, skipping all mounted file systems below /. Note that -xdev does not cause / to be skipped, even though it is a mount point. This is because / is the starting point and -xdev only affects entries below starting points.

cd /; find . -xdev -print | cpio -pdm /Disk

Change permissions on all regular files in a directory subtree to mode 444, and permissions on all directories to 555:

find /tmp -type f -print | xargs chmod 444
find /tmp -type d -print | xargs chmod 555

Access Control List Examples Find all files not owned by user root

find / ! -user root

Find and print root directories only

find / -maxdepth 1 -type d

Make copy of subset of dir/ and below

find dir/ -name '*txt' | xargs cp -a --target-directory=dir_txt/ --parents

Search for files inside many paths

find . -regex '/dir[0-9] '

Find files named core in or below the directory /tmp and delete them. Note that this will work incorrectly if there are any filenames containing newlines or spaces.

find /tmp -name core -type f -print | xargs /bin/rm -f

Find files named core in or below the directory /tmp and delete them, processing filenames in such a way that file or directory names containing spaces or newlines are correctly handled.

find /tmp -name core -type f -print0 | xargs -0 /bin/rm -f

to find the files that were accessed yesterday:

find ~ -daystart -type f -atime 1

Find a string in files starting cwd

find . -exec egrep -li "str" {} \;

Find without traversing NFS mounted file systems

find / -fstype nfs -prune -o fstype autofs -prune -o -name filename -print

Find recently modified files

find . -mtime -1 -type f

Find files modified during the past # of days

find / -mtime <# of days>

Finds and removes files older than < days> specified

find . ! -mtime -< days> | /usr/bin/xargs rm -rf

Find files containing < sub-string> within directory tree

find . -type f -exec grep "< sub-string>" {} \; -print

Recursive grep on files

find . -type f -print | xargs grep -i [PATTERN]

Find all files owned by < username>

find / -user < username>

Fast way to search for files

find / | grep [file mask]

Recursively finds files by name and automatically removes them

find / -name "< file_name>" -exec rm -rf {} \;

Find large files held open by a process

find /proc/fd -links 0 -type f -size +2000 -ls

Search file and directory into root filesystem from '/'

find / -name file1

Search files and directories belonging to 'user1'

find / -user user1

Search files with '. bin' extension within directory '/ home/user1'

find /home/user1 -name \*.bin

Search binary files are not used in the last 100 days

find /usr/bin -type f -atime +100

Search files created or changed within 10 days

find /usr/bin -type f -mtime -10

Search files with '.rpm' extension and modify permits

find / -name \*.rpm -exec chmod 755 '{}' \;

Search files with '.rpm' extension ignoring removable partitions as cdrom, pen-drive, etc..

find / -xdev -name \*.rpm

To find all files not owned by user or group

find / -nouser -o -nogroup -ls

To find all files modified in last 24 hours

find / -mtime 1 -o -ctime 1

Find files newer than reference file

touch /tmp/reference_file
sleep 5
touch /etc/passwd
find /etc -newer /tmp/reference_file -follow -type f

Deletes files from /tmp directory and subdirs not accessed in the last 30 days:

find /tmp -type f -mtime +30 -exec rm -i {} \;

Find files larger than 10MB on the system

find / -type f -size +10240k

Listing all files under current dir

find . -depth -print


finger _____________________ user info lookup program

For detailed options see:

man finger

If you have Lnternet access, get latest kernel info:

finger @finger.kernel.org


fmt _____________________ simple optimal text formatter

For detailed options see:

man fmt

cformats the lines in the file my_file.txt to the width of 80 characters.
It breaks long lines and joins short lines as required, but doesn't remove
empty lines

fmt -w 80 file1.txt > file2.txt


for _____________________ loop construct

For detailed options see:

man for

rang controlled loop - print out dec, oct hex numbers

for ((x=0; x <= 127; x++)); do
printf '%3d | %04o | 0x%02x\n' "$x" "$x" "$x"

List controlled loop using 'for' construct - copy files from different locations for each_file in /tmp/file1 /var/tmp/file2 /opt/tmp/file3

cp $each_file /tmp/$each_file.bak


gnome-control-center _____________________ control panel for Gnome

Linux control panel (allows to add custom icons)



     export PATH=/usr/local/sbin:/usr/local/bin:/sbin:/bin:/usr/sbin:/usr/bin
     rpm -q control-center
     if [ $? != 0 ]; then
      echo ""
      echo "please, install package:    control-center  and run $0 again"
      echo ""
     mkdir -p $ccpath 2>/dev/null
     echo "install finished"
     if [ $? != 0 ]; then
      echo "install finished !"
      echo "RESTART X SESSION (ctrl-alt-backspace)"
      echo "login to graphic desktop and run:"
      echo "gnome-control-center"
    DE='[Desktop Entry]'
    echo -e "$COMMON
    Comment=Authentication configurator
    Icon=user_icon" >$ccpath/authentication.desktop
    echo -e "$COMMON
    Comment=Boot loader configurator
    Icon=gnome-planner" >$ccpath/boot.desktop
    echo -e "$COMMON
    Name=Date & Time
    Comment=Authentication configurator
    Icon=gnome-clock" >$ccpath/date.desktop
    echo -e "$COMMON
    Comment=Display properties configurator
    Icon=gnome-color-xterm" >$ccpath/display.desktop
    echo -e "$COMMON
    Name=Gnome Display Manager
    Comment=Gnome Display Manager configurator
    Icon=gdm-setup" >$ccpath/gdm.desktop
    echo -e "$COMMON
    Name=WEB server
    Comment=WEB server configurator
    Icon=neat-control" >$ccpath/httpd.desktop
    echo -e "$COMMON
    Comment=Authentication configurator
    Icon=control-center2" >$ccpath/kickstart.desktop
    echo -e "$COMMON
    Comment=Authentication configurator
    Icon=gkb" >$ccpath/kickstart.desktop
    echo -e "$COMMON
    Name=System Logs
    Comment=Authentication configurator
    Icon=system-logviewer" >$ccpath/logviewer.desktop
    echo -e "$COMMON
    Comment=Authentication configurator
    Icon=disks" >$ccpath/lvm.desktop
    echo -e "$COMMON
    Name=Mouse Detect
    Comment=Authentication configurator
    Icon=gnome-mouse" >$ccpath/mouse.desktop
    echo -e "$COMMON
    Comment=Netboot configurator
    Icon=neat" >$ccpath/netboot.desktop
    echo -e "$COMMON
    Name=Network Settings
    Comment=Authentication configurator
    Icon=neat-control" >$ccpath/network.desktop
    echo -e "$COMMON
    Comment=Packages configurator
    Icon=system-config-packages" >$ccpath/packages.desktop
    echo -e "$COMMON
    Comment=Authentication configurator
    Icon=cupsprinter" >$ccpath/printer.desktop
    echo -e "$COMMON
    Comment=Samba file sharing configurator
    Icon=gnome-netstatus-tx" >$ccpath/samba.desktop
    echo -e "$COMMON
    Comment=Authentication configurator
    Icon=gnome-error" >$ccpath/securitylevel.desktop
    echo -e "$COMMON
    Comment=Services configurator
    Icon=gdm-xnest" >$ccpath/services.desktop
    echo -e "$COMMON
    Name=Sound Card
    Comment=Sound Cards configurator
    Icon=redhat-sound_video" >$ccpath/soundcard.desktop
    echo -e "$COMMON
    Name=Switch Mailer
    Comment=Mailer configurator
    Icon=switchmail" >$ccpath/switch-mail.desktop
    echo -e "$COMMON
    Name=System Monitor
    Comment=System REsources Monitor
    Icon=gnome-monitor" >$ccpath/system-monitor.desktop
    echo -e "$COMMON
    Comment=Automatic updates configurator
    Icon=applet-okay" >$ccpath/up2date.desktop
    echo -e "$COMMON
    Comment=Users configurator
    Icon=user_auth" >$ccpath/users.desktop
    echo -e "$COMMON
    Name=Sound Mixer
    Comment=Sound Mixer
    Icon=gnome-mixer" >$ccpath/volumecontrol.desktop


gnome-sound-properties _____________________ sound configurator

Requires full gnome environment to run properly. It can test sound events,
music and movies sound, audio converencing.
It can set system events sounds and enable/disable system beep.



grep _____________________ print lines matching a pattern

For detailed options see:

man grep

grep = "Global Regular Expression Print"

grep comes from the ed command to print all lines matching a
certain pattern 'g/re/p' where "re" is a "regular expression".

Look up words "Aug" on file '/var/log/messages'

grep Aug /var/log/messages

Look up words that begin with "Aug" on file '/var/log/messages'

grep ^Aug /var/log/messages

Select from file '/var/log/messages' all lines that contain numbers

grep [0-9] /var/log/messages

Search string "Aug" at directory '/var/log' and below

grep Aug -R /var/log/*

Show CPU(s) info

grep "model name" /proc/cpuinfo

Paint suz keywords from a file

grep --color suz /usr/share/dict/words

Show RAM total seen by the system

grep MemTotal /proc/meminfo

Show lines containing cpu

grep cpu /proc/cpuinfo

count lines in a file

grep -c "" filename

Count CPUs (available cores) that server has

grep -c ^processor /proc/cpuinfo

Find all files from /etc that contain word eth0

grep -r eth0 /etc

List (non)matching files

grep -l root /etc/* # matching
grep -L root /etc/* # nonmatching

Print all but empty lines from a file

grep -v ^$ /tmp/file1

To search a file for lines that contain either a Dec or Nov, use either of the following commands:

grep -E '[Dd]ec|[Nn]ov' file
egrep -i 'dec|nov' file

Search all files in the current directory for the string xyz:

grep xyz *

Grep for string and also show line numbers

grep -n user1 /etc/passwd

Get all possible four letters word starting with da

grep "^da..$" /usr/share/dict/words

Find all executables files in directory

ls -lR /tmp| grep "\-x" | grep -v "dr"

Deleting ALL blank lines from a file

grep "." testfile.txt > newfile.txt

Deleting ALL blank lines from a file

grep [[:space:]] testfile.txt > newfile.txt

Get info on last reboot operations

grep -n syslogd /var/log/messages

Count number of files from current dir to all sub-dirs

echo "No of files under $(pwd) and sub-dirs: $(ls -l * | grep -c . )"


gtv _____________________ MP3 and video (MPEG-1) player with GTK+ GUI

Start Audio and video player



gunzip _____________________ compress or expand files

For detailed options see:

man gunzip

Extract gz files inside current directory

gunzip *

Extract a single file

gunzip file1.gz

locate all the gzip archives in the current path and check if they are valid archives:

find . -name '*.gz' | xargs gunzip -vt


gzip _____________________ compress or expand files

For detailed options see:

man gzip

To tar and gzip a single file:

tar cf - /path/to/filename | gzip > filename.tar.gz

Compress a file called 'file1'

gzip file1

Compress with maximum compression

gzip -9 file1

Burn cdrom image (use dev=ATAPI -scanbus to confirm dev)

gzip -dc cdrom.iso.gz | cdrecord -v dev=/dev/cdrom -

compress all files on the current directory

gzip *

compress initrd after being ungzipped

gzip -v9c initrd >initrd.zg

Save copy of cdrom iso image and zip it

gzip < /dev/cdrom > cdrom.iso.gz

Burn cdrom image (use dev=ATAPI -scanbus to confirm dev)

gzip -dc cdrom.iso.gz | cdrecord -v dev=/dev/cdrom -
(requires ide-scsi for cdrom enabled)


head _____________________ output the first part of files

For detailed options see:

man head

Print firs five characters of the file

head -c5 /etc/passwd

Print first five lines of the file

head -5 /etc/passwd


info _____________________ A stand-alone TTY-based reader for GNU texinfo

For detailed options see:

man info

For detailed options see:

man pinfo

show top-level dir menu


For detailed options see:

man info

info emacs

start at emacs node from top-level dir

info emacs buffers

start at buffers node within emacs manual

start at node with emacs' command line options

info --show-options emacs

show file ./foo.info, not searching dir

info -f ./foo.info


if _____________________ conditional case construct

Simple example conditional construct

     if true; then
        echo yes

If-Else Statement in Korn Shell

     if [ Condition1 ]
      block A1
     elif [ Condition2 ]
      block A2
     elif [ Condition3 ]
      block A3
     elif [ Condition i-1 ]
      block Ai-1
      block Ai

If-Else Statement in csh Shell

     if ( Expression1 ) then
        block A1
     else if ( Expression2 )
        block A2
     else if ( Expression3 )
        block A3
     else if ( Expression i-1 )
        block Ai-1
        block Ai


ifconfig _____________________ configure a network interface

For detailed options see:

man ifconfig

show state of all interfaces

ifconfig -a

Show configuration of an ethernet network card

ifconfig eth0

Configure IP Address

ifconfig eth0 netmask

Configure 'eth0' in promiscuous mode to gather packets (sniffing)

ifconfig eth0 promisc

Tune eth nunla interface for a better performance (valid till reboot)

ifconfig eth0 mtu 1500

SuSE network bug which affect wmware client networking Wrong, named by yast /etc/sysconfig/network/ifcfg-eth-bus-pci-0000:00:11.1

Correct, given on startup /etc/sysconfig/network/ifcfg-eth-id-00:0C:29:39:78:AA

Try to change interface MAC

ifconfig eth1 hw ether 04:32:35:25:ae:ee

Try to add virtual interface on the fly (valid till reboot)

ifconfig eth0:1 netmask

Bring virtual interface up

ifconfig eth0:1 up

Bring virtual interface down

ifconfig eth0:1 down

Two addressess for one interface (virtual interface) - RedHat



init _____________________ process control initialization

For detailed options see:

man init

reboot system

init 6

halt system

init 0

switch to a single user mode and stop all services

init 1

enter text mode

init 3

start full graphic mode (Xorg and display manager needed to be installed)

init 5

Confirm and read into kernel all changes that you've made on /etc/inittab

init q
/etc/inittab is configuration file used by the init process

Major parameters used for defining inittab lines:

      id:runlevel:style:command to run
      1. id - A 1-4 character field the creates a unique identifier for the entry
      2. runlevel - Specifies the runlevel(s) that the entry applies to
      3. style - Specifies how the command is executed
        . respawn:      - Process is restarted every time it dies
        . wait:         - Start process once and wait for it to finish
        . once:         - Execute process once when enetering specified runlevel
        . sysinit:      - Execute during boot before any boot or bootwait entries
        . boot:         - Executed during system boot (runlevel field is ignored)
        . bootwait:     - Same as boot, except init will wait for it to complete
        . initdefault:  - Specifies default run level (command field is ignored)
        . powerwait:    - Execute when power goes down and wait to complete
        . powerfail:    - Same as powerwait and don't wait for completing
        . powerokwait:  - Executed when power is restored and wait to complete
        . powerfailnow: - Executed when battery on UPS is almost dead
        . ctrlaltdel:   - Process executed when CTRL+ALT+DEL was pressed
      4. command - Specifies process to execute


jobs _____________________ display status of jobs in the current session

to see jobs at the current terminal



join _____________________ join lines of two files on a common field

For detailed options see:

man join

The following command line joins the password file and the group file, matching on the numeric group ID, and outputting the username, group, the login directory and login shell.

join -1 4 -2 3 -o 1.1 2.1 1.6 1.7 -t: /etc/passwd /etc/group

The -o 0 field essentially selects the union of the join fields. For example, given file phone:

join -t "[tab]" -a 1 -a 2 -e '(unknown)' -o 0,1.2,2.2 phone fax

The following command produces an output consisting all possible combinations of lines that have identical first fields in the two sorted files sf1 and sf2, with each line consisting of the first and third fields from sorted_file1 and the second and fourth fields from sorted_file2:

join -j1 1 -j2 1 -o 1.1, 2.2, 1.3, 2.4 sorted_file1 sorted_file2


kcontrol _____________________ kde Control center

Can set add-ons for KDE and some system settings



kill _____________________ signal a process

For detailed options see:

man kill

See for all available signals that can be used with kill

man 7 signal

Force closure of the process and finish it

kill -9 ID_Process

Force a process to reload configuration

kill -1 ID_Process

Reload syslog service using kill command

kill SIGINT $(cat /var/run/syslogd.pid)
kill -2 syslogd

Simulate killall command (kill all httpd processes)

kill $(ps -ef | grep httpd | awk '{print $2}')

Terminate process many different ways

kill -s SIGKILL 1234
kill -s KILL 1234
kill -s 9 1234
kill -SIGKILL 1234
kill -KILL 1234
kill -9 1234

Show all possible signals

kill -l


0 SIGNULL Null Check access to pid
1 SIGHUP Hangup Terminate; can be trapped
2 SIGINT Interrupt Terminate; can be trapped
3 SIGQUIT Quit Terminate with core dump; can be trapped
9 SIGKILL Kill Forced termination; cannot be trapped
15 SIGTERM Terminate Terminate; can be trapped
24 SIGSTOP Stop Pause the process; cannot be trapped
25 SIGTSTP Terminal stop Pause the process; can be trapped
26 SIGCONT Continue Run a stopped process


killall _____________________ kill processes by name

For detailed options see:

man killall

also see:


Kill all similar processes by name
(if custom sh script runs of of control)

killall -9 bash sh


kmix _____________________ audio mixer for KDE








konqueror _____________________ Web browser, file manager, ..

Faster browsing

In KDE 3.2, a little-known but useful option has been added to speed up
your web browsing experience. Start the KDE Control Center and choose
System > KDE performance from the sidebar. You can now select to preload
Konqueror instances. Effectively, this means that Konqueror is run on
startup, but kept hidden until you try to use it.

Starting konqueror in kiosk mode:

konqueror --profile KIOSK https://localhost:10000

define profile KIOSK:

vi /root/.kde/share/apps/konqueror/profiles/KIOSK

[Main Window Settings]
[Main Window Settings Toolbar Speech Toolbar]
[Main Window Settings Toolbar bookmarkToolBar]
[Main Window Settings Toolbar extraToolBar]
[Main Window Settings Toolbar locationToolBar]
[Main Window Settings Toolbar mainToolBar]
[Main Window Settings Toolbar mainMenu]


kpm _____________________ Process manager for KDE

To run 'top' like process manager

(right click to access options and send some signals)


let _____________________ bash built-in commands, see bash(1)

define value for variable a

let a=11

calculate value for variable a

let a=a+5

divide value of variable a

let a=a/3


let a=a-3


let a=a*3

rise value of variable a by 1

let a++

decrease value of variable a by 1

let a--


less _____________________ A text file browser similar to more

For detailed options see:

man less

See start of some file:

less /tmp/bigfile
pgUp/pgDn # browse more
q # exit less command

Try less with line numbering

less -N /etc/passwd

Switch to vi edit mode using less

while scrolling file with less, just press: v


logout _____________________ Logout of a login shell

For detailed options see:

man logout

Leaving session



locate _____________________ find files by name

For detailed options see:

man locate

Search cached index for names. This re is like glob *file*.txt

locate -r 'file[^/]*\.txt'

Exclude filesystems and directories from updating (edit fiile):


Update locate database:

see updatedb


ln _____________________ make hard/soft links between files

For detailed options see:

man ln

Creating soft links:

ln -s /etc /var/tmp/etc

Soft links are usefull for linking among different partitions.
Hard links will only work on the same partition/filesystem.
Reason for that are inodes which have different i-numbers on
different filesystems, so filename can not point to them.

Create a physical link to file

ln file1 lnk1

The following command creates fl1 and fl2 in destination_dir,
which are linked back to the original files fl1 and fl2. If files on destination
already exist, they will be removed.

ln -f fl1 fl2 destination_dir


ls _____________________ list directory contents

Perform long listing and mark executable files with asterisk

ls -bCAFl

get ls to do thousands grouping appropriate to locale

BLOCK_SIZE=\'1 ls -l

Print colored output

ls --color

List files with full detailed creation time

ls --full-time -t

Show files, last changed - last

ls -lahtr

List files by date.

ls -lrt

Show size of the files and directories ordered by size

ls -lSr |more

List files and directories and mark them like: add asterisk for executables
and slash for directories:

ls -F

List directories only at the current path:

ls -d */

Use -d switch to list all hidden files and directories at the current path:

ls -d .*

Show file attributes and ownership

ls -la /tmp/file1

Show files with hidden characters in names

ls -b /tmp/*

Show files info node numbes

ls -la -i /tmp

Show human readable file sizes

ls -lah /tmp

Counting files and subdirs in directory

ls -l |wc -l

To list files sorted by size:

ls -Sl

Revers sort all files by size

ls -laSr

Find all files containing ls in their names

ls -lR | grep ps

View files of directory


View files of directory

ls -F

Show details of files and directory

ls -l

Show hidden files

ls -a

Knowing inode number of files

ls -ail

Show files and directory containing numbers

ls *[0-9]*

List biggest files in the current directory last

ls -lShr

list without owners info

ls -lg *

multicolumn output into file

ls -C

give me sorted listing

ls -Slh /

for detailed options see:

man ls


man _____________________ display system doc

For detailed options see:

man man

biggest man pages collections on web


show man on ls command

man ls

list all available man pages on the system

man -k [aeiou]|sort|uniq

Get manual pages that start with man (similar to whatis)

man -f man

To get a plain text ver. of a man page, without backspaces and
underscores, try

man find | col -b > find.txt

How to write man pages


Get a custom breaked lines from man pages output:

unset LANG
(echo ".nr LL 18.i"; zcat '/usr/share/man/man8/yum.8.gz')|
gtbl | nroff -mandoc |col -b

Make man pages immune to local codepage set:

NROFF /usr/bin/groff -Tlatin1 -mandoc
NEQN /usr/bin/geqn -Tlatin1

Where are the GNU Reference Manuals?


If man pages are formatting incorrectly with PuTTY, try editing

the "/etc/man.config" file with the following changes:
NROFF /usr/bin/groff -Tlatin1 -mandoc
NEQN /usr/bin/geqn -Tlatin1

Creating a Manpage

As root you can copy the following to
which will give you a manpage for examples:
.\" Manpage for examples.
.\" Contact om8000@hotmail.com to correct errors or omissions.
.TH man 1 "examples"
examples \- man page for examples
collection of linux and open source tips.
no options.
ls(1), ps(8)
No known bugs at this time.
oTo (om8000@hotmail.com )

man pages sections

1 user commands, general commands
2 system calls
3 library functions, Subroutines
4 special files
5 file formats
6 games and demos
7 macros and conventions
8 administration and privileged commands
9 kernel interfce
L math library functions
N tcl functions

also see command below for fast simple man page generation:


man2ps - requires postscript installed

man -t manpage > manpage.ps


mount _____________________ connect filesystems

For detailed options see:

man mount

Show mounted filesystems on the system (and align output)

mount | column -t

Mount the cdrom image at /mnt/dir (read only)

mount -o loop cdrom.iso /mnt/dir

Mount a windows share

mount -t smbfs -o fmask=666,guest //windows_box/share /mnt/share

Mount a windows network share

mount -t smbfs -o username=user,password=pass //WinClient/share /mnt/share

Mounting iso image file

mount -o loop /tmp/test.iso /mnt

Mounting a /proc filesystem easy way:

mount /proc

hard way (if easy one fails):

mount -n -t proc proc /proc

Mountan iso image file:

mount -o loop -t iso9660 /img.iso /mnt

Make iso image auto mount at boot time:
Put the following into /etc/fstab

/img.iso /mnt iso9660 ro,loop 0 0

Remount readonly filesystem:

mount -o remount,rw /

Mount ext2 formatteed floppy

mount -t ext2 /dev/fd0 /mnt/floppy

Mount a floppy disk

mount /dev/fd0 /mnt/floppy

Mount a cdrom / dvdrom

mount /dev/cdrom /mnt/cdrom

Mount a cdrw / dvdrom

mount /dev/hdc /mnt/cdrecorder

Mount a cdrw / dvdrom

mount /dev/hdb /mnt/cdrecorder

Mount a file or iso image

mount -o loop file.iso /mnt/cdrom

Mount a WIN FAT32 file system

mount -t vfat /dev/hda5 /mnt/hda5

Mount a usb pen-drive or flash-drive

mount /dev/sda1 /mnt/usbdisk

Mounting old outdated zip drives
If ZIP drive has been recognised by the kernel ... (dmesg)

modprobe ide-floppy
mount /dev/hdaN /mnt/floppy


mv _____________________ move (rename) files

For detailed options see:

man mv

Rename a file in the current directory:

mv old-filename new-filename

Rename a directory in the current directory:

mv old-dirname new-dirname

Rename a file in the current directory whose name starts with a nonprinting
control character or a character that is special to the shell, such as -
and * (extra care may be required depending on the situation):

mv ./bad-filename new-filename
mv ./?bad-filename new-filename
mv ./*bad-filename new-filename

Move directory sourcedir and its contents to a new location (targetdir) in
the file system (upon completion, a subdirectory named sourcedir resides
in directory targetdir):

mv sourcedir targetdir

Move all files and directories (including links) in the current
directory to a new location underneath targetdir:

mv * targetdir

Move all files and directories (including links) in sourcedir to a new
location underneath targetdir (sourcedir and targetdir are in separate
directory paths):

mv sourcedir/* targetdir

results with the original files a and b residing
in the directory d in the current directory.

mv a b c
mv c d


more _____________________ file perusal filter for crt viewing

For detailed options see:

man more

Display file contents page by page

more /tmp/bigfile

Display contents of all files in the current directory:

more *

Switch to vi edit mode using more
while scrolling file contents using more, just press:


To preview nroff output, use a command resembling:

nroff -mm +2 doc.n | more -s

If the file contains tables, use:

tbl file | nroff -mm | col | more -s

To display file stuff in a fifteen line-window and convert multiple
adjacent blank lines into a single blank line:

more -s -n 15 stuff

To examine each file with its last screenful:

more -p G file1 file2

To examine each file starting with line 100 in the current position
(third line, so line 98 is the first line written):

more -p 100g file1 file2

To examine the file that contains the tagstring tag with line 30 in the current position:

more -t tag -p 30g

The -p allows arbitrary commands to be executed at the start of each file.

more -p G file1 file2

Examine each file starting with its last screenful.

more -p 100 file1 file2

Examine each file starting with line 100 in the current position
(usually the third line, so line 98 would be the first line written).

more -p /100 file1 file2


mkpasswd _____________________ generate new random password

For detailed options see:

man mkpasswd

Creating random password example:

mkpasswd -l 9 -d 2 -C 3


mesg _____________________ control write access to your terminal

For detailed options see:

man mesg

Allow other people to send you messages to the console

mesg y

Do not allow other users to send you messages using write or wall

mesg n


mkdir _____________________ create a directory

For detailed options see:

man mkdir

Create two directories simultaneously

mkdir dir1 dir2

Create directory g1 inside existing directory r1 in the current directory:

mkdir r1/d1

Create complete subdirectory structure at once

mkdir -p /tmp/d1/d2/d3

Create directory path d1/d2/d3 underneath the current directory and
set permissions on directory diamond to read-only for all users (a=r):

mkdir -p -m "a=r" d1/d2/d3
mkdir -p -m 444 d1/d1/d3

Creating many directories using curly braces expansion

mkdir -p /work/junk/{one,two,three,four}


nautilus _____________________ Nautilus is a file manager for GNOME.

start file explorer style

nautilus --browser

Samba browser -- basically "Network Neighborhood"

nautilus smb:///

Font browser. Click on font to see stuff.

nautilus fonts:///

Access the top of My Computer

nautilus computer:///

Access network shares

nautilus network:///

preparation for burning to CD

nautilus burn:///

Displays a whole bunch of themes. You can change your

theme from here
nautilus themes:///

browse certain directory

nautilus file:///etc/


neat _____________________ network configurator

see: system-config-network



neat-tui _____________________ tui network configurator

see: system-config-network-tui



nice _____________________ run a program with modified scheduling priority

For detailed options see:

man nice

Run a low priority command (info in this case)

nice info

Run a program named prog in the current directory at the default priority_change

nice ./prog prog_args

Run the same program in the background

nice -12 ./prog prog_args &

Run prog as a foreground process

nice --14 ./prog prog_args


nl _____________________ number lines of files

For detailed options see:

man nl

Just nubler lines of file

nl /etc/passwd

Number file1 starting at line number 5, using an increment of 5. The logical page delimiter is +:

nl -v5 -i5 -d+ /etc/passwd

Reversing file lines using nl

nl -ba /tmp/file1 | sort -nr | cut -d'' -f2-


noatun _____________________ music player for KDE

to run properyl it need up and running KDE with sound support and services



od _____________________ dump files in octal and other formats

For detailed options see:

man od

Simple octal output

od /etc/passwd

Write hexadecimal bytes and the corresponding octal values to the
standard output in blocks of 16 bytes in one line

od -tx1oC /etc/passwd

The following commands write one line each of the types character,
signed decimal integer, and float, in the order given, transforming
100 bytes of data starting from fifteenth byte offset in the file file1:

od -j14 -N100 -tc -tdfF /etc/passwd

Write one line each of the types unsigned integer, named character, and
long double, with the offsets written in hexadecimal and forcing a write

od -v -Ax -tuafL /etc/passwd

Creating random nubers from urandom device

od -An -N2 -tu < /dev/urandom


passwd _____________________ setting/changing passwords

For detailed options see:

man passwd

Show all /etc/passwd users command prompt:

~< tab >< tab >

Change password for the current user:


Lock an account as root user (insert '!!' in password place):

passwd -l user1

Change password for another user (as root):

passwd user1

Remove user password:

passwd -d user1

Lost password:

Log in to Single user mode. At the LILO boot prompt type in :
linux 1 init=/bin/sh root=/dev/hdaN mount rw
(where N is the number of your root partition).
Then change the password for root with the command:


paste _____________________ merge lines of files

For detailed options see:

man paste

List directory in two tab separated columns:

ls | paste -d"\t" - -

Combine pairs of lines into lines

paste -s -d"\t\n" file
1. Write out a directory in four columns:
ls | paste - - - -
2. Combine pairs of lines from a file into single lines:
paste -s -d "\t\n" file

Merging contents of two files for columns

paste file1 file2

Merging contents of two files for columns with '+' delimiter on the center

paste -d '+' file1 file2

For detailed options see:

man paste


pr _____________________ convert text files for printing

For detailed options see:

man pr

Print in 9 columns to width of terminal

ls /usr/bin | pr -T9 -W$COLUMNS

Print txt file with left margin

cat /tmp/textfile |pr -t -o 4 -w 80|lpr

Print passwd and group as a double spaced, three column listing headed by file list:

pr -3dh "PASSWD & GROUP" /etc/passwd /etc/group

Write file1 on file2, expanding tabs to columns 10, 19, 28, 37, ... :

pr -e9 -t < file1 > file2

Print file1 in default format with nonblank lines numbered down the left:

nl file1 | pr

paginate or columnate text files for printing. To write file1 on file2, expanding tabs to columns 10, 19, 28, ... :

pr -e9 -t < file1 >file2

paginate or columnate text files for printing. To print a numbered list of all files in the current directory:

ls -a | pr -n -h "Files in $(pwd)."


ps _____________________ report a snapshot of the current processes

For detailed options see:

man ps

State codes output by ps command

D uninterruptible sleep (usually IO)
R runnable (on run queue)
S sleeping
T traced or stopped
Z a defunct ("zombie") process

List processes by % cpu usage

ps -e -o pcpu,cpu,nice,state,cputime,args --sort pcpu | sed '/^ 0.0 /d'

List processes in a hierarchy

ps -e -o pid,args --forest

List processes by mem usage

ps -e -orss=,args= | sort -b -k1,1n

Show detailed processes info

ps auwwx

Show in details and include environment

ps aeuwwx

Displays linux tasks

ps -eafw

Displays linux tasks in a hierarchical mode

ps -e -o pid,args --forest

Show tree structure

ps -axlf

List info for particular process IDs

ps -p 1,2

List all threads for a particular process

ps -C firefox-bin -L -o pid,tid,pcpu,state

Show users and jobs

ps -efl | cut -c 5-15,84-

Show a very extensive data on running jobs

ps aeuwwx

List processes in a hierarchy

ps -e -o pid,args --forest

List processes by mem usage.

ps -e -orss=,args= | sort -b -k1,1n | pr -TW$COLUMNS

To see every process on the system using standard syntax:

ps -e
ps -ef
ps -eF
ps -ely

To see every process on the system using BSD syntax:

ps ax
ps axu

To sort processes by pid numbers

ps -aux

To print a process tree:

ps -ejH
ps axjf

To get info about threads:

ps -eLf
ps axms

To get security info:

ps -eo euser,ruser,suser,fuser,f,comm,label
ps axZ
ps -eM

To see every process running as root (real & effective ID) in user format:

ps -U root -u root u

To see every process with a user-defined format:

ps -eo pid,tid,class,rtprio,ni,pri,psr,pcpu,stat,wchan:14,comm
ps axo stat,euid,ruid,tty,tpgid,sess,pgrp,ppid,pid,pcpu,comm
ps -eopid,tt,user,fname,tmout,f,wchan

Print only the process IDs of syslogd:

ps -C syslogd -o pid=

Print only the name of PID 42:

ps -p 42 -o comm=

Getting a List of Users on the System

cut -d: -f1 /etc/passwd | sort

Show 'hungry' processes

ps -ef | grep -v '0:00'

Show dependency tree

ps -fu

Show hierarhic tree when searching for zombie, to kill its parent

ps -efH


pstree _____________________ display a tree of processes

For detailed options see:

man pstree

Show process tree structure


on other unix-es


show as much as possible infos

pstree -aAclpuZ

show tree with processes numbers

pstree -p


pwd _____________________ return working directory name

Print cuurent working directory example


Print cuurent working directory disregarding symbolic link

pwd -P


rmdir _____________________ remove empty directories

For detailed options see:

man rmdir

To remove empty directory with a prompt for verification:

rmdir -i directory

To remove as much as possible of a path, of empty directories type:

rmdir -p component1/component2/dir

To remove directory including files:

rm -r /tmp/subdir1


rm _____________________ remove files or directories

For detailed options see:

man rm

Create a safe remove command:
On your system you should put this one into /etc/profile to make it
available for all users. See also function command.

Good think: Instead of removing files and dirs for real, you will save
them into .Trash directory. This function should also prevent all
features of rm -rf to stop a real damage. To rum a real rm command, you
will need to use a full path otherwise you will never remove files for real.

function rm {
mkdir ~/.Trash 2>/dev/null
mv $@ ~/.Trash 2>/dev/null

Remove files with a prompt for verification:

rm -i file1 file2

Remove all the files in a directory:

rm -i mydirectory/*

Remove a file in the current directory whose name starts with - or * or
some other character that is special to the shell:

rm ./-filename
rm \*filename

Remove a file in the current directory whose name starts with some
strange (usually nonprinting, invisible) character:

rm -i *filename*

A powerful and dangerous command to remove a nonempty directory is:

rm -rf dir_name

Remove a whole system while it is running!

# /bin/rm -rf /*

Delete file called 'file1'

rm -f file1

Delete directory called 'dir1'

rmdir dir1

Remove a directory called 'dir1' and contents recursively

rm -rf dir1

Remove two directories and their contents recursively

rm -rf dir1 dir2

Destroy a whole linux server, all settings and programs (DANGEROUS):

#rm -rf /*


read _____________________ read a line from standard input

For detailed options see:

man read

Print a file with the first field of each line moved to the end of the line

     while read -r xx yy
       printf "%s %s \n" "$yy" "$xx"
     done < input_file

Read value into variable (interactive)

echo -en "Please input some value"; read a
echo "$a is the value"


renice _____________________ alter priority of running processes

For detailed options see:

man renice

Make shell (script) low priority. Use inside shell script

renice 19 -p $$

Make an existing process running at lower priority (+10)

renice 10 28454

change the priority of process ID's 987 and 32, and all processes owned by users daemon and root.

renice +1 987 -u daemon root -p 32


rpm _____________________ a perl only implementaion of a RPM header reader

For detailed options see:

man rpm

Install a rpm package

rpm -ivh package.rpm

Install a rpm package ignoring dependencies requests

rpm -ivh --nodeps package.rpm

Forcely remove package

rpm -e httpd --nodeps

Upgrade a rpm package without changing configuration files

rpm -U package.rpm

Upgrade a rpm package only if it is already installed

rpm -F package.rpm

Remove a rpm package

rpm -e package_name.rpm

Show all rpm packages installed on the system

rpm -qa

Show all rpm packages with the name "httpd"

rpm -qa | grep httpd

Obtain info on a specific package installed

rpm -qi package_name

Show rpm packages of a group software

rpm -qg "System Environment/Daemons"

Show list of files provided by a rpm package installed

rpm -ql package_name

Show list of configuration files provided by a rpm package installed

rpm -qc package_name

Show list of dependencies required for a rpm packet

rpm -q package_name --whatrequires

Show capability provided by a rpm package

rpm -q package_name --whatprovides

Show scripts started during installation / removal

rpm -q package_name --scripts

Show history of revisions of a rpm package

rpm -q package_name --changelog

Verify which rpm package belongs to a given file

rpm -qf /etc/httpd/conf/httpd.conf

Show list of files provided by a rpm package not yet installed

rpm -qp package.rpm -l

Import public-key digital signature

rpm --import /media/cdrom/RPM-GPG-KEY

Verify the integrity of a rpm package

rpm --checksig package.rpm

Verify integrity of all rpm packages installed

rpm -qa gpg-pubkey

Check file size, permissions, type, owner, group, MD5 checksum and last modification

rpm -V package_name

Check all rpm packages installed on the system - use with caution

rpm -Va

Verify a rpm package not yet installed

rpm -Vp package.rpm

Extract executable file from a rpm package

rpm2cpio package.rpm | cpio --extract --make-directories *bin*

Install a package built from a rpm source

rpm -ivh /usr/src/redhat/RPMS/`arch`/package.rpm

Determine which package some file belongs to

rpm -qf /bin/ls /sbin/ifcfg
NOTICE: can be specified more than one files, separated by spaces, but
no more than 3432 (RPM ver. 4.4.2).

Install rpm package

rpm -ivh package*.rpm

Get doc locations on installed rpms

rpm -q heartbeat -d

Remove package

rpm -e package

Update package (never perform that for Kernel packages)

rpm -Uvh package*.rpm

Query all packages by their sizes

rpm -qa --qf '%10{SIZE} %{NAME}\n' | sort -n

Count installed packages on the system

prm -qa|wc -l

Repair broken rpm database - if rpm is not responsive:

rm /var/lib/rpm/__db*

Verify a single rpm file changes agains original install

rpm -qV httpd

Verfy all rpm packages

rpm -qaV
rpm -Va

Find all packages containing string php

rpm -qa|grep php

Many CentOS and RedHat packages



sed _____________________ stream editor for filtering and transforming text

For detailed options see:

man sed

A good tutorial on sed


Good sed examples


Only operate on lines that contains certain string

sed -e '/matching_string/s/$/<\/tr>/'

Give me first title from html file and exit

sed -n "s/.*< title>\(.*\)< \/title>.*/\1/ip;T;q" index.html

Append empty line text and another empty line after matching one

sed -e "/one/ a \nNumber is one\n" tetfile

Remove comments and blank lines

sed '/ *#/d; /^ *$/d' ./file1

Concatenate lines with trailing backslash

sed ":a; /\$/N; s/\n/; ta" ./file1

Print lines 10 to 20

sed -n "10,20p;20q" ./file1

Print 1000th line

sed -n "1000p;1000q" ./filea1

Extract title from HTML web page

sed -n "s/.*< title >\(.*\)<\ /title >.*/\1/ip;T;q" ./file1

Remove trailing spaces from lines

sed "s/[ \t]*$//" ./file1

Modify anystring1 to anystring2

sed "s/\(.*\)1/\12/g" ./file1

Replace string1 with string2

sed "s/string1/string2/g" ./file1

Join every two lines where first line ends with (1)

sed -e '$!N;s/ (1) \n/ (1) /' 1

delete the first 10 lines of a file

sed '1,10d'

line numbers separated with tab

sed = /etc/passwd- | sed 'N;s/\n/\t/'

use eval to enforce variable substitutions

foo="abc"; eval sed 's/def/$foo/' /etc/passwd-

remove all lines that contains hashes

sed -e '\#\d' /etc/httpd/conf/httpd.conf

delete the last line of a file

sed '$d'

display only lines having the specified pattern

sed -n '/false/p' /etc/passwd-

delete the last 2 lines of a file

sed 'N;$!P;$!D;$d'

delete the last 10 lines of a file

sed -e :a -e '$d;N;2,10ba' -e 'P;D' # method 1
sed -n -e :a -e '1,10!{P;N;D;};N;ba' # method 2

Replace "string1" with "string2" in example.txt

sed 's/stringa1/stringa2/g' example.txt

Remove all blank lines from example.txt

sed '/^$/d' example.txt

Remove comments and blank lines from example.txt

sed '/ *#/d; /^$/d' example.txt

Convert from lower case in upper case

echo 'esempio' | tr '[:lower:]' '[:upper:]'

Eliminates the first line from file example.txt

sed -e '1d' result.txt

View only lines that contain the word "string1"

sed -n '/stringa1/p'

Remove empty characters at the end of each row

sed -e 's/ *$//' example.txt

Remove only the word "string1" from text and leave intact all

sed -e 's/stringa1//g' example.txt

View from 1th to 5th row

sed -n '1,5p;5q' example.txt

View row number 5

sed -n '5p;5q' example.txt

Replace more zeros with a single zero

sed -e 's/00*/0/g' example.txt

To print out a block of text that begins with a line containing "Mat", and ending with a line that contains "Pat":

sed -n '/Mat/,/Pat/p' /tmp/some-file

Replace spaces in filenames with underscores

for i in * *; { mv ''$i'' $(echo $i | sed 's/ /_/g'); }

Recursive replacement of empty psaces for files and dir names

[ $# -ne "1" ] && echo "Usage: $0 dir_path" && exit 1
find $1 -name "* *" | sed 's/^.*$/mv \"&\"/g' > t1$$
find $1 -name "* *"|sed -e 's/ /_/g' -e 's/^.*$/\"&\"/g' >t2$$
paste t1$$ t2$$ > t3$$; sh t3$$; #rm -f t?$$

Append after matching lines

sed -e '/#boot/a password md5 $1$UmclT$P0acPGXL3h1HOyz9bzoSS1' /boot/grub/menu.lst


shift _____________________ shift positional parameters

For detailed options see:

man shift

switch positional parameters and echo files

    until [ -z "$1" ] # test if string is zero lenght
      echo -n "$1 "

Create backups of specified files

    for each_f in $@
     cp $each_f $each_f.bak


sort _____________________ Sorting and merging lists

For detailed options see:

man sort

Sort IPV4 ip addresses

echo -e "\n10.20.11.10\n192.168.10.15" |
sort -t. -k1,1n -k2,2n -k3,3n -k4,4n

You could also search for the biggest MP3/MPEGs:

ls -l *.mp* | sort -k 4

Sort on STDIN


Finding the biggest files

ls -l | sort -k 4

numeric sort can be combined with awk to put numbers fields first

ls -l|awk '{print ,}'|sort -n

sort files by type

ls -l |sort

Fast sorting:

cat all_files_possible |sort -r -n --temporary-directory=/dev/shm

Sort the contents of infile with the second field as the sort key:

sort -k 2,2 infile

Sort, in reverse order, the contents of infile1 and infile2, placing the
output in outfile and using the first two characters of the second field
as the sort key:

sort -r -o outfile -k 2.1,2.2 infile1 infile2

Sort, in reverse order, the contents of infile1 and infile2, using the
first non-blank character of the fourth field as the sort key:

sort -r -k 4.1b,4.1b infile1 infile2

Print the password file (/etc/passwd) sorted by numeric user ID (the third
colon-separated field):

sort -t: -k 3n,3 /etc/passwd

Print the lines of the presorted file infile, suppressing all but the
first occurrence of lines having the same third field:

sort -mu -k 3,3 infile

Sort contents of two files

sort file1 file2


source _____________________ Evaluate a file or resource as a Tcl script

For detailed options see:

man source

Read and execute commands from filename in the current shell environment and return the exit status of the last command executed from filename.

source /tmp/myscript.sh

used for profile configuration files

source ./.profile
source ./.bash_profile
source ./.profile


startix _____________________ starting X server from console

For detailed options see:

man startx

Start X session from physical terminal


Running multiple X sessions (from physical terminal)

startx --:1
startx --:2


stat _____________________ show detailed information on file attributes

For detailed options see:

man stat

Show numeric and descriptive permissions of a file

stat /bin/ls|grep Access


switchdesk _____________________ GUI and TUI mode interface for choosing desktop environment

runs in console or gui mode

switchdesk KDE

to see or list available desktops


to force tui mode under X



system-config-display _____________________ GUI configuring the X Window System display

RedHat specific, needs X or system console to operate, configure graphics


The following display settings can be set

settings: resolution, color depth
hardware: monitor, videocard
dual head: on/off, 2nd monitor, 2nd videocard, color depth, desktop layout


system-config-network _____________________ The GUI of the NEtwork Adminstration Tool

RedHat specific, auto select TUI or GUI net configurator


also try: neat



system-config-network-tui _____________________ The NEtwork Adminstration Tool

RedHat specific, TUI, configure network interfaces


also try: neat-tui



system-config-printer _____________________ A printer administration tool

RedHat specific, needs X to operate, configure printers



system-config-soundcard _____________________ GUI for detecting and configuring soundcards

RedHat specific, needs X to operate, configures sound card



strings _____________________ show printable characters in binary files

For detailed options see:

man strings

Remove ^M andall other control chars within the file

strings filename.ext > newfile.ext


talk _____________________ Talk client for one-on-one Internet chatting

For detailed options see:

man talk

Potentially dangerous! Requires talk server to be running!
To talk to another user, just try:

talk user2


tac _____________________ concatenate and print files in reverse

For detailed options see:

man tac

View the contents of a file starting from the last line

tac file1


tail _____________________ output the last part of files

For detailed options see:

man tail

Print 10 last lines of a file

tail /tmp/test.txt

Print 20 last lines of a file

tail -20 /tmp/test.txt

Follow the real-time changes in log file

tail -f /var/log/messages


tar _____________________ The GNU version of the tar archiving utility

For detailed options see:

man tar



Make a incremental backup of directory '/home/user'

tar -Puf backup.tar /home/user

Local copy preserving permits and links from a directory to another

tar cf - . | (cd /tmp/backup ; tar xf - )

Create a uncompressed tarball

tar -cvf archive.tar file1

Create an archive containing 'file1', 'file2' and 'dir1'

tar -cvf archive.tar file1 file2 dir1

Show contents of a zipped archive

tar -ztf archive.tar

Show contents of a bzipped archive

tar -jtf archive.tar

Show contents of an archive

tar -tf archive.tar

Extract a tarball

tar -xvf archive.tar

Extract a tarball into / tmp

tar -xvf archive.tar -C /tmp

Create a tarball compressed into bzip2

tar -cvfj archive.tar.bz2 dir1

Decompress a compressed tar archive in bzip2

tar -xvfj archive.tar.bz2

Create a tarball compressed into gzip

tar -cvfz archive.tar.gz dir1

Decompress a compressed tar archive in gzip

tar -xvfz archive.tar.gz

Make archive of dir/

tar c dir/ | bzip2 > dir.tar.bz2

Make encrypted archive of dir/ on remote machine

tar c dir/ | gzip | gpg -c | ssh user@remote "dd of=dir.tar.gz.gpg"

Make archive of subset of dir/ and below

find dir/ -name '*.txt' | tar c --files-from=- | bzip2 > dir_txt.tar.bz2

Copy (with permissions) copy/ dir to /where/to/ dir

( tar c /dir/to/copy ) | ( cd /where/to/ && tar x -p )

Copy (with permissions) contents of copy/ dir to /where/to/

( cd /dir/to/copy && tar c . ) | ( cd /where/to/ && tar x -p )

Copy (with permissions) copy/ dir to remote:/where/to/ dir

( tar c /dir/to/copy ) | ssh -C user@remote 'cd /where/to/ && tar x -p'

Copy (with permissions) copy/ dir to /where/to/ dir

( tar c /dir/to/copy ) | ( cd /where/to/ && tar x -p )

Copy (with permissions) copy/ dir to remote:/where/to/dir

( tar c /dir/to/copy )|ssh -C user@remote 'cd /where/to/ && tar x -p'

Make archive of dir/

tar c dir/ | bzip2 > dir.tar.bz2

Extract archive (use gzip instead of bzip2 for tar.gz files)

bzip2 -dc dir.tar.bz2 | tar x

Make encrypted archive of dir/ on remote machine

tar c dir/ | gzip | gpg -c | ssh user@remote 'dd of=dir.tar.gz.gpg'

Recursively copy files and their permissions

tar cf - . | (cd /newdir ; tar xf -)

Create an archive of /bin and /usr/bin (c), show the command working (v),
and store on the tape in /dev/rmt0:

tar cvf /dev/rmt0 /bin /usr/bin

List the tape's contents in a format like ls -l:

tar tvf /dev/rmt0

Extract the /bin directory:

tar xvf /dev/rmt0 /bin

Create an archive of the current directory and store it in a file
backup.tar: (The - tells tar to store the archive on standard output,
which is then redirected.)

tar cvf - `find . -print` > backup.tar

Filter an archive through gzip, extracting the contents but leaving the
original file compressed:

tar xvfz chapters.tar.gz

Create crypted archive of /etc:

tar zcvf - /etc|openssl des3 -salt -k passw0rd | dd of=/dev/st0
-Reading the data back-
dd if=/dev/st0|openssl des3 -d -k passw0rd|tar xzf -

Remove all files accidentally unpacked to current dir

rm -f $(tar ftz package.tar.gz)

Complete archive of your system:
To make it usable, first add the followint to file: /exclude


Now run:
tar --exclude-from /exclude -zcvf /backup.tgz /

See the contetnts of archive or follow changes for archive in progress:
(NOTICE: if archiving is saking too long while observing archive
from another console, this can produce timeout error)

tar ztvf /backup.tgz

Find all files with '.log' extention and make an bzip archive

find /var/log -name *.log | tar cv --files-from=- | bzip2 > log.tar.bz2

To back up, or to copy between filesystem/ directory without
loosing any info on the files/dirs do:

$(tar cvf - /backup-path) | ( cd /where-to-copy; tar xvf - )

To create a tarball of a directory, excluding all symlinked files within that dir:

find data-dir-path ! -type l ! -type d tar -zcvf filename.tgz -T-

To search the contents of a .tar.bz2 without decompressing

tar -tjf file.tar.bz2

To make a tarball to only files that have been changed since DATE:

tar -N DATE -zcvf incr-backup.tgz /dir-to-backup
DATE string could be in one of the following formats:
'11:00 today','today','yesterday', '6 days ago','2008-03-13', '13Mar', 'March 13, 04', '13Mar04'

Tar copy over ssh

tar zcvf - /local-data-dir-or-file | ssh -C \
user@remoteserver tar -zxvf - -C /remote-data-dir-path


tee _____________________ read from standard input and write to standard output and files

For detailed options see:

man tee

tee = T

To take a lateral output. Taken from plumbing terminology for a T-shaped pipe splitter.

Show output of ls command on the screen and also save it into a file

ls |tee /tmp/tee.txt


telinit _____________________ process control initialization

For detailed options see:

man telinit

see: init



test _____________________ provides a simple framework for writing test scripts

For detailed options see:

man test

Exit if there are not two or three arguments (two variations):

if [ $# -ne 2 -a $# -ne 3 ]; then exit 1; fi
if [ $# -lt 2 -o $# -gt 3 ]; then exit 1; fi

Perform a mkdir if a directory does not exist:

test ! -d tempdir && mkdir tempdir

Wait for a file to become non-readable:

     while test -r thefile
      sleep 30
     echo '"thefile" is no longer readable'

Perform a command if the argument is one of three strings (two variations):

     if [ "$1" = "pear" ] || [ "$1" = "grape" ] || [ "$1" = "apple" ]
     case "$1" in
      pear|grape|apple) command ;;


then _____________________ conditional if loop construct

see: if



top _____________________ display top CPU processes

For detailed options see:

man top

For better tool also try:


top is text mode process table explorer

will show: cpu, memory, swap utilization, load avg and uptime
will not show: cpu info, system info, platform type ...

Show processes status every second and operate top interactivelly

sort processes by memory
sort processes by CPU
show all CPUs
exit top

show processess status every two seconds and run only three times

top -d2 -n3

create output that is suitable for saving into a file

top -d10 -n100 >/tmp/top.txt

Monitor process identifier (PID) 2233 and 4455, you type:

top -p 2233,4455

Monitor processes by root user only

top -u root

Monitor processes by UID 0 only:

top -U 0


tr _____________________ translate or delete characters

For detailed options see:

man tr

WARNING Never use the same file for output redirection or you will loose all your data!

CORRECT: cat /etc/passwd|tr a-z A-Z >/tmp/passwd
WRONG & DESTRUCTIBLE: cat /etc/passwd|tr a-z A-Z >/etc/passwd

Change all low cases to upper ones

cat /etc/passwd|tr a-z A-Z
cat /etc/passwd|tr '[:lower:]' '[:upper:]'

Break a whole file into a single words each word is in its own line, separators are all non-letters(digits)

cat /etc/passwd|tr -cs '[:alnum:]' '[ *]'

Create 100MB big file containing readabble random characters

tr -dc '[:print:]' < /dev/urandom |
dd bs=1024 count=100000 >/tmp/bigfile

Delete all a's, 0's, b's and 1's from stream

cat /etc/passwd|tr -d -- a0b1

Convert each sequence of repeated newlines to a single newline

cat /etc/test|tr -s n

Squeeze repeated characters or signs or spaces to one single

cat /etc/test|tr -s _

Change uppercase to lowercase in a file:

cat file | tr 'A-Z' 'a-z'

Turn spaces into newlines (ASCII code 012):

tr ' ' ' ' < file

Strip blank lines from file and save in new.file (or use 011 to change successive tabs into one tab):

cat file | tr -s "" " " > new.file

Delete colons from file and save result in new.file:

tr -d : < file > new.file

This example uses an equivalence class to identify accented variants of the base character 'e' in file1, which are stripped of diacritical marks and written to file2.

tr "[=e=]" e < file1 >file2

For the ASCII character set and default collation sequence, create a list of all the words in file1, one per line in file2, where a word is taken to be a maximal string of alphabetics. Quote the strings to protect the special characters from interpretation by the shell (012 is the ASCII code for a new-line (line feed) character):

tr -cs "[A-Z][a-z]" "[\012*]" < file1 >file2

Same as above, but for all character sets and collation sequences:

tr -cs "[:alpha:]" "[\012*]" < file1 >file2

Translate all lower case characters in file1 to upper case and write the result to standard output.

tr "[:lower:]" "[:upper:]" < file1

Use an equivalence class to identify accented variants of the base character e in file1, strip them of diacritical marks and write the result to file2:

tr "[=e=]" "[e*]" < file1 >file2

Translate each digit in file1 to a # (number sign), and write the result to file2.

tr "0-9" "[#*]" < file1 >file2

dos2uix using tr

cat dos.txt | tr -d '\015' > unix.txt

Printing available system paths in readable way

echo $PATH | tr ':' '\n'


true _____________________ do nothing, successfully

For detailed options see:

man true

This command repeats date and time printing without an end
Condition will allways be true because true command is used

     while true
      sleep 1

Return exit status 0

echo $?


type _____________________ write a description of command type

For detailed options see:

man type

Find out all aliases, functions, real paths for ls command:

type -all ls

show types for all commands in bin directory

for each in $(ls /bin); do type $each; done


umount _____________________ disconnect filesystems

For detailed options see:

man umount

Umount mounted filesystem

umount /mnt/cdrom

Run umount without writing the file /etc/mtab - useful when
the file is read-only or the hard disk is full

umount -n /mnt/hda2


unexpand _____________________ convert spaces to tabs

For detailed options see:

man unexpand

unexpand copies files (or the standard input) to the standard
output, putting TAB characters back into the data

unexpand space-data-file.dat > tab-data-file.dat


updatedb _____________________ update database for whatis command

Update path for locate command (see also: locate)


Updatedb creates a database of all installed files and saves
usually to /usr/local/var/locatedb. Certain entries waste time
and space. Rename and make a symlink, or make a script with:

updatedb --prunepaths="/var /tmp /mnt /cdrom /floppy /proc"


vi _____________________ visual interactive

vi cheat sheet

    vi Cheat Sheet
    :--------------------------------------------------:  :-----------------:
    | COMMAND MODE                                     |  |                 |
    |                                                  |  |                 |
    |  :--------[coomand mode to edit mode]---------:  |  |                 |
    |  |        I          i [] a         A         |--+--+--> EDIT MODE    |
    |  `--------------------------------------------´  |  |    text typing  |
    |                                                  |  |        |        |
    |  cut, copy, paste    join lines  cursor move     |  |        |        |
    |  :---------------:   :----:      :------------:  |  |        |        |
    |  | dd  yy    p   |   | J  |      |     1G     |  |  |     back to     |
    |  `---------------´   `----´      |     k      |  |  |     command     |
    |                                  | ^ h [] l $ |  |  |     mode        |
    |  delete char,word    save+exit   |      j     |  |  |        |        |
    |  :--------------:    :-------:   |      G     |  |  |      [ESC]      |
    |  | x    X    dw |    |  ZZ   |   `------------´  |  |        |        |
    |  `--------------´    `-------´                 <-+--+--------´        |
    |                                   onetime        |  |                 |
    |  ex mode   search, repeat         undo,redo      |  |                 |
    |  :----:    :----------------:     :--------:     |  |                 |
    |  | :  |    |  /    n        |     | u  .   |     |  |                 |
    |  `----´    `----------------´     `--------´     |  |                 |
    |     |                                 ^          |  |                 |
    `-----|---------------------------------|----------´  `-----------------´
          |                                 |
    | EX MODE                               |          |
    |                                  :----+------:   |
    |  search & replace                |  [esc]    |   |
    |  :-----------------:             |  [enter]  |   |
    |  | :%s /old/new/g  |             `-----------´   |
    |  `-----------------´                             |
    |                                                  |
    |  change settings    save, exit                   |
    |  :-------------:    :-------------------------:  |
    |  | :set ...    |    | :w :w! :q :q! :wq :x    |  |
    |  `-------------´    `-------------------------´  |
    |                                                  |


vlock _____________________ Virtual Console lock program vlock

To lock current console or terminal


To lock all physical consoles

vlock -a


whoami _____________________ print effective userid

For detailed options see:

man whoami

Give me my username:



who _____________________ show who is logged in

For detailed options see:

man who

Get inf oabout logged in users


Show who is logged on, and print: time of last system boot, dead
processes, system login processes, active processes spawned by init,
current runlevel, last system clock change

who -a

Get detailed info with times and processes

who --all

Give me info only about me

who am I -or- who am i -and also see whoami-

Get runlevel and date using who:

who -r


wall _____________________ send a message to all connected users

Send a administrative message to all users:

wall "Server will bew rebooted in 5 minutes"

Someone can also redirect message from a file

wall < admin.msg


write _____________________ send a message to another user

Write message to user1

write user2

Write message back to user root

write root #(This way two way communication is established (simple chat).)


wc _____________________ print the number of newlines, words, and bytes in files

For detailed options see:

man wc

Give me number of lines in a file

wc -l /etc/passwd

Give me nuber of words and characters:

wc -w -c /etc/passwd


webmin _____________________ A web-based administration interface for Unix systems.

a very good unix/linux system configuration tool over the web

to access: firefox https//localhost:10000


whereis _____________________ locate the binary, source, and manual page files for a command

For detailed options see:

man whereis

Find files with the '.ps' extension - first run 'updatedb' command
locate \*.ps show location of a binary file, source or man

whereis halt

Get info for ls command

whereis ls

Find all the files in /usr/bin that are not documented in
/usr/share/man/man1 with source files in /usr/src/comm:

cd /usr/bin
whereis -u -M /usr/share/man/man1 -S /usr/src/comm -f *

Find man pages for all files in /bin directory

whereis -m -u /bin/*

For detailed options see:

man whereis


which _____________________ shows the full path of (shell) commands

For detailed options see:

man which

Show full path and aliases for the ls command

which ls

also see: whereis



while _____________________ Execute script repeatedly as long as a condition is met

For detailed options see:

man while

Count from 1 to 9 while condition example (bash)

     while ((i <= 9))
      echo " $i "
      printf " $i "
      (( i = $i + 1))

Infinite loop using 'while' construct - simulate watch

     while true
      sleep 1


X _____________________ graphical - GUI server

Open remote session to server that allows you to

X -query

X -query for /etc/fstab entry

x:5:respawn:/usr/bin/X11/X -query -fp tcp/ :7100

configure Xorg server automatically

X -configure
-then run the following to test new configuration-
X -config /root/xorg.conf.new


xmms _____________________ an audio player for X

To start this winamp like player just execute:


for detailed options see:

man xmms


xlock _____________________ Locks the local X display

To lock X session


Lock the screen with a different screensaver

xlock -mode forest

show all possible options on xlock

xlock --help


yast _____________________ Yet another Setup Tool

Mostly for SuSE based distros

tui & gui setup tool

to use textmode:


to use graphical interface:


to use yast on redhat:



zcat _____________________ expand and concatenate data

Peek inside compressed file

zcat arcgive.gz|more

for detailed options see:

man zcat


command _____________________ desc








Podstrani (1): ctrl