1/07/2011 Unix, Linux, and BSD: Command Line Cheat Sheet

The following command line cheat sheet for Unix, Linux, and BSD systems is from my new book Introduction to the Command Line (available now a Amazon.com).

Help Commands

man - Online manual
whatis - Displays manual descriptions

File and Directory Commands

ls - Lists directory contents
pwd - Prints the current directory
cd - Change directories
mv - Move files
cp - Copy files
rm - Delete files
mkdir - Create directories
rmdir - Remove directories
find - Search for files (slow)
locate - Search for files (faster)
whereis - Display binary file location
which - Display binary file location
file - Display file type
size - Display file size
stat - Display file statistics
fuser - Identify open files
touch - Update file timestamps
lsof - List open files
cksum - Calculate checksum
md5sum - Calculate md5sum
ln - Create a link
alias - Display/edit command aliases
gzip - Compress files
gunzip - Uncompress files
shred - Securely delete files
head - Display the head of a file
tail - Display the tail of a file
tee - Display and redirect output
sort - Sort input files/streams
grep - Display matching results
tree - Display directory tree
more - Display files one page at a time
less - Display files one page at a time
wc - Count words/lines/letters
cat - Display files
zcat - Display compressed files
diff - Show differences between files
strings - Display printable characters
sed - Text editing utility
awk - Text processing utility
dos2unix - Convert DOS files to Unix
unix2dos - Convert Unix files to DOS


nano - Simple text editor
vi - Advanced text editor
emacs - Ultimate text editor

Other Utilities

clear - Clear terminal screen
date - Display the date
cal - Display a calendar
watch - Monitor a command
env - Display environment variables
history - Display command history
logout - Logout of the shell
exit - Exit the shell

Users and Groups

su - Switch user
sudo - Run a program as another user
id - Display user identity
ulimit - Display user limits
who - Display who is logged in
w - Display what users are doing
users - Display active user accounts
last - Display last user logins
lastlog - Display all user’s last login
wall - Send a message to all users
whoami - Display current user id
finger - Display information about a user
chown - Change file/directory ownership
chgrp - Change file/directory group
chmod - Change file/directory permissions
umask - Display or set umask settings
passwd - Set/change password
useradd - Create user accounts
userdel - Delete user accounts
usermod - Modify user accounts
groupadd - Create group accounts
groupdel - Delete group accounts
groupmod - Modify group accounts

Process Control

ps - Display running processes
pgrep - Search for running processes
pidof - Search for PID by name
pstree - Displays process in tree view
kill - Terminate a process by PID
killall - Terminal a process by name
nice - Run a program with a modified priority
renice - Adjust a program's priority
nohup - Run a program immune to hang-ups
& - Run a program in the background
bg - Move a job to the background
jobs - Display running jobs
fg - Move a job to the foreground

Startup and Shutdown

shutdown - Shutdown the computer
poweroff - Poweroff the computer
halt - Halt the computer
runlevel - Display the current runlevel
telinit - Change runlevel
service - Stop and stop services
sysv-rc-conf - Runlevel configuration editor
update-rc.d - Debian runlevel editor
chkconfig - Red Hat runlevel editor
rc-update - Gentoo runlevel editor
rc-status - Gentoo service monitor

Networking Commands

hostname - Display the system hostname
domainname - Display the system domain
ifconfig - Manage network interfaces
ifup - Start network interfaces
ifdown - Stop network interfaces
iwconfig - Manage wireless interfaces
iwlist - Display wireless information
ethtool - Display network card info
arp - Display the ARP cache
ping - Send ICMP echo requests
traceroute - Trace network paths
tracepath - Trace network paths
nslookup - Query DNS servers
dig - Query DNS servers
host - Query DNS servers
whois - Query the whois database
dhclient - Linux DHCP client
netstat - Display network status
route - Manage network routes
tcpdump - Capture network packets
nmap - Scan remote computers
wavemon - Monitor wireless connections
smbtree - Display SMB servers/shares
nmblookup - Look up NetBIOS information
mount - Mount file systems
showmount - Show mounted file systems
umount - Unmount file systems
ssh - SSH client
telnet - Telnet client
ftp - FTP client
ncftp - Scriptable FTP client
mail - Email client
rsync - Rsync client

Hardware Commands

lspci - List PCI devices
pcidump - List PCI devices
lsusb - List USB devices
lshw - List hardware devices
lspcmcia - List PCMCIA devices
lshal - Display all system hardware
hdparm - Configure hard drives
eject - Eject removable media


batch - Run processes when the CPU is free
at - Run processes at a specific time
atq - Display the at queue
atrm - Remove jobs from the at queue
crontab - Display/edit cron jobs

File System Commands

fdisk - Partition editor
parted - Partition editor
mkfs - Create file systems
fsck - Check file systems
mkswap - Create swap space
swapon - Activate swap space
swapoff - Deactivate swap space
sync - Flush disk cache

Backup Commands

tar - Archive utility
dd - File copy utility
dump - Incremental backup utility
restore - Restore dump backups
mt - Tape device utility
cpio - Archive utility

Monitoring Commands

top - Performance monitor
mpstat - Performance monitor
vmstat - Virtual memory monitor
iostat - I/O performance monitor
nfsstat - NFS performance monitor
free - Display memory usage
df - Display disk usage
du - Display disk usage
uname - Display system information
uptime - Display system uptime
lsmod - List kernel modules
modinfo - Display module information
dmesg - Display kernel messages
strace - System trace debugger
ltrace -Library trace debugger
ipcs - IPC monitor
sysctl - Configure kernel parameters

Printing Commands

lp - Print files
lpstat - Display printer status
lpq - Display print queue
lprm - Remove print jobs
cancel - Cancel print jobs
enable - Enable a printer
disable - Disable a printer

Software Commands

dpkg - Debian package manager
apt-get - Debian package utility
rpm - Red Hat package manager
yum - Red Hat package utility
emerge - Gentoo package utility
pkg_add - BSD installation utility
pkg_delete - BSD uninstallation utility
make - Compile software from source
Digg it StumbleUpon del.icio.us

0 comentarios:

Post a Comment