Linux Commands

Everyday Linux Administration Commands

Linux: System Information Commands

Linux Command Description
w Display Who is online and their processes
who Show who is logged on
whoami Display effective userid
id Display user and groups
groups Display the groups a user is in
finger user Display user information
uname -a Display Kernel Information
man command Display man pages for specified command
man -k keyword Search man pages for referenced keyword
apropos keyword Search man pages names and descriptions for specified keyword
df -h Display Disk Usage in MB and GB
du Display an estimate of file space usage
free Display Memory and Swap Information
dmesg Display kernel ring buffer. Often used as - dmesg | grep -i "search-string"
uptime Displays system uptime since boot and system Load averages
runlevel Displays previous and current runlevel of system
hostname Displays hostname of system
chkconfig --list Displays System services run levels
env Display current environment
lsusb List USB devices
lspci List all PCI devices
lshw List hardware (run as root user)
lshal List items in HAL Database
tty Print the name of the terminal attached to Standard Input

Linux: File and Directory Commands

Command Description
ls List files in current directory
ls -l List files in current directory using long listing method
ls -a List hidden files in current directory (Files prefixed with a "." dot)
ls -rtl List files in reverse time order using long listing method
ls -F List files in current directory, display directories with a trailing slash "/"
ls -i List files in current directory, display inode information
cd dir Change to Directory dir
cd .. Change to a directory one level higher than current directory
cd ~ Change to home Directory of current user
cd - Change to previous directory
pwd Display current Directory
rm file Delete specified file
rm -fr dir Delete Directory dir and its contents
rm -i Confirm Deletion with the "-i" option by replying "y" when prompted
cp file1 file2 Copy file1 to a file called file2
cp -r dir1 dir2 Copy Directory dir1 to directory dir2
mv file1 file2 Rename or move file1 file2
touch file Create or update a file
cat file1 Display content of file1
cat file1 file2 > file3 Concatenate contents of file1 and file2 and send to a new file called file3
tac Same as cat command, however file contents are reversed
strings Display printable characters from within a file
more file Display the contents of the specified file
head file Display the first 10 lines of a file
tail file Display the last 10 lines of a files
less file Display the contents of the specified file
> file Nulls file (makes file Zero bytes in size)
file file Display file type: ASCII text, executable, binary etc..
ln -s file link Create symbolic link link to file

Linux: Search Commands

Command Description
grep pattern path Search for pattern in the following path
grep -i Search for upper or lowercase patterns
grep -r Recursive Search
grep -v Inverted Search
find dir -name pattern Find files by name in directory dir
find dir -user userid Find files owned by userid in directory dir
whereis command Locate the binary source/location of specified command
which command Display path used for specified command
locate pattern Locate file by pattern or name. Files must be previously indexed.