Website Design » Basic Linux Commands


Basic Linux Commands

Linux common commands in: logical order / Alphabetical Order

ls
List files and directories

Usage:
ls -ladetailed list of all files and directories
ls -lahadd human readable file sizes
ls -lathadd sort by modification time

#Help from the shell
man ls
ls --help

 

 

cd
Change directory

Usage:
cd /homechange directory to /home
cd -P /dirnamechange to /dirname (but if a symbolic link change to physical directory link points to)
cd /usr/local/binmove 3 directories deep to /usr/local/bin

#Help from the shell (type these commands from the shell prompt)
man cd

 

 

clear
Clear the display

Usage:
clearclear the display screen
Add link for 'cls'ln -s `which clear` /usr/local/bin/cls

#Help from the shell
man clear

 

 

who
Show login information

Usage:
whoshows user, terminal, login date & time
who -dshows dead processes
who -rprints current run level
who -bDisplay date of last system boot

#Help from the shell
man who
who --help

#Related Commands
w, finger

 

 

find
Find files recursively in a directory structure

Usage:
find .list all files to display
find . > /tmp/filelist.txtstore same list in a file called filelist.txt
find /tmp -name \*.htmllist all html files in /tmp directory

#Help from the shell
man find
find --help

 

 

grep
Search file contents to match a pattern. Lines with matching patterns are output.

Usage:
grep dog file.txtoutput every line containing dog in file.txt
grep -v dog file.txtoutput every line not containing dog

#Help from the shell
man grep
grep --help

 

 

cat
Output and concatenate file contents.

Usage:
cat file.txtoutput contents of file.txt to display
cat -n file.txtprefix each line with a number
cat file1 file2 > file3concatenate file1 and file2 into file3

#Help from the shell
man cat
cat --help

 

 

less
Display file contents one page at a time with backward and forward movement.

Usage:
less file.txtdisplay contents of file.txt one page at a time
less -P%B file.txtdisplay contents of file.txt with custom prompt

#Help from the shell
man less
less --help

 

 

echo
Output a line of text to display

Usage:
echo "Part Number:"Display Part Number:
echo -e \\t"Part Number:"Insert tab in front of text
echo -n "Part Number:"suppress newline

#Help from the shell
man echo

 

 

 

 

Back to Top
Copyright © 2007 WebsiteDesignElixirs.com