Support Center > Knowledgebase > Web Host Manager > cPanel and Linux > Is there a cheat sheet for these shell commands ?
Is there a cheat sheet for these shell commands ?
Yes, there are countless "Linux newbie" tutorials out there.
The following is a breakdown of the most commonly used commands and the most commonly used arguments for them.
- ls — Lists files and directories in a directory, comparable to dir in Windows® /DOS.
- ls -al — Shows all files (including those with filenames starting with a period), directories, and details for each file.
- cd — Changes the directory in which you are working.
- cd /usr/local/apache — Go to the /usr/local/apache/ directory.
- cd ~ — Go to your home directory.
- cd - — Go to the last directory you were in.
- cd .. — Go "up" a directory (to the directory containing the current one).
- cat — Print file contents to the screen.
- cat filename.txt — cat the contents of filename.txt to your screen.
- tail — Like cat, but only reads the end of the file.
- tail /var/log/messages — See the last 20 (by default) lines of /var/log/messages
- tail -f /var/log/messages — Watch the file continuously, while it's being updated.
- tail -200 /var/log/messages — Print the last 200 lines of the file to the screen.
- more — Like cat, but opens the file one screen at a time, rather than all at once,
- more /etc/userdomains — Browse through the userdomains file. Hit to go to the next page, and
to quit.
- pico — Friendly, easy-to-use text editor for editing files. A clone of it is nano.
- pico /home/user1/public_html/index.html — Open the index page of the user's website for editing.
- vi — Another text editor, harder to use at first than pico, but much more powerful.
- vi /home/user1/public_html/index.html — Open the index page of the user's website for editing.
- grep — Looks for patterns in files.
- grep root /etc/passwd — Shows all matches of root in the file /etc/passwd.
- grep -v root /etc/passwd — Shows all lines that do not match root in the file /etc/passwd.
- touch — Creates an empty file.
- touch /home/user1/public_html/404.html — Creates an empty file called 404.html in the directory /home/user1/public_html/.
- ln — Creates links between files and directories.
- ln -s /usr/local/apache/conf/httpd.conf /etc/httpd.conf — This lets you edit /etc/httpd.conf rather than the original (/usr/local/apache/conf/httpd.conf). Changes will affect the orginal; however, you can delete the link without deleting the original.
- rm — Deletes a file.
- rm filename.txt — Deletes the file filename.txt, and will more than likely ask if you really want to delete it.
- rm -f filename.txt — Deletes the file filename.txt, and will not ask for confirmation before deleting.
- rm -rf tmp/ — Recursively deletes the directory tmp, and all files in it, including subdirectories. ALERT! Warning: Be VERY CAREFUL with this command!
- last — Shows who logged in and when.
- last -20 — Shows only the last 20 logins.
- last -20 -a — Shows the last 20 logins, with the hostname in the last field.
- w — Shows who is currently logged in and where they are logged in from.
- netstat — Shows all current network connections.
- netstat -an — Shows all connections to the server, including the source and destination IPs and ports.
- netstat -rn — Shows a routing table for all IPs bound to the server.
- file — Attempts to guess the file type by looking at its content.
- file * : prints out a list of all files and directories within a directory.
- du — Shows disk usage.
- du -sh — Shows a summary, in human-readable form, of total disk space used in the current directory, including subdirectories.
- du -sh * — Same as above, but for each file and directory. This is helpful when finding large files taking up space.
- wc — Displays word count for a file.
- wc -l filename.txt — Tells how many lines are in filename.txt.
- cp — Copies a file.
- cp filename filename.backup — Copies the file filename to filename.backup.
- cp -a /home/user1/new_design/* /home/burst/public_html/ — Copies all files, retaining permissions form one directory to another.
Also Read