Linux without a shell access is like a Mac without a mouse. But Linux power users get more done precisely because there is no mouse. Small programs that do one thing well is a design philosophy that epitomizes the Linux world; getting comfortable with which command is the right one for the job, is half the struggle; getting up to speed with actually using those commands to improve your daily productivity is the other half—just what do all those switches really do?
Shell commands fall into several broad categories: directories, files, discovery, file systems, security, installation, networking, logging, administration, and compression. Here are some commonly used commands:
category | command | useful switches | task |
---|---|---|---|
Directories | cd | Change to a new directory. | |
mkdir | Make a new directory. | ||
rmdir | Delete and existing directory. | ||
pwd | Show full path of current working directory. | ||
ln | -s | Create a symbolic link to a file or directory. | |
Files | less | Display a file's contents a page at a time. | |
head | -n | Display the first few lines of a long file. | |
tail | -n | Display the last few lines of a long file. | |
cat | Display an entire file (without stopping). | ||
cp | Copy a file. | ||
mv | Move a file. | ||
rename | Rename a file. | ||
rm | Delete a file. | ||
touch | Create an empty file. | ||
pico | Edit a file. (use 'x' to exit) | ||
Discovery | ls | -lia | List directory contents. |
locate | Find a file when you only know its name. | ||
find | -name | Find files that match certain criteria. | |
grep | -r | Find all files that contain a given string. | |
apropos | Find a Linux command that has something to do with . . . | ||
man | Show help text for a command | ||
File systems | mount | Mount a device. | |
umount | Unmount a device. | ||
df | -h | Show disk free space. | |
du | /path/ -sh | Show disk usage for a directory. | |
sfdisk | -l | List partition table. | |
fsck | Check and repair file system errors after rough shutdown. | ||
Security | adduser | Create a new user account. | |
passwd | Set the password for an account. | ||
id | Show current user's numeric id and group id. | ||
chown | Change the file owner. | ||
chgrp | Change the file group membership. | ||
chmod | 700 - | Change file permissions. | |
710 e | |||
720 w | |||
740 r | |||
sudo | Execute a super-user command. | ||
Installation | yum | search list install upgrade |
Download and install a utility, service, or application. |
uname | -a | Show Linux kernel number. | |
Networking | ping | Check for reachability. | |
ifconfig | Show NIC status. | ||
ifup | Bring a NIC online. | ||
ifdown | Take a NIC offline. | ||
traceroute | Show host-to-host hops. | ||
iptables | -L | Show firewall rules. | |
nslookup | Use DNS to find a domain address. | ||
nmap | -sS | Scan a host for listening ports. | |
netstat | -tea -tean |
Show status of listening and established TCP connections. | |
tcpdump | TCP/IP packet analyzer. | ||
Logging | who | Show who is currently logged in. | |
w | Show who is currently logged in. | ||
last | Show successful logins. | ||
lastb | Show unsuccessful attempts. | ||
Administration | ps | axu | Current processes. |
pstree | -pG | Current processes in tree format. | |
kill | Terminate a process. | ||
top | Show real-time activity and usage. | ||
free | Show memory usage. | ||
uptime | How long has this computer been up. | ||
shutdown | Shutdown. | ||
Compression | tar | cvpzf | Create a compressed .tgz tarball |
tar | xzf | Extract a .tgz tarball. | |
gzip | -c | Compress into .gz file. | |
gunzip | -c | Decompress from .gz file. |