Commands Cheatsheet
Updated Feb 24, 2021 ·
Directory
Commands | Description |
---|---|
pwd | Displays the current directory |
ls | Lists the contents of a directory |
ls -la | Lists the contents but also shows permissions, user, group, size, and date/time created. |
ls -latr | Similar with ls -la, but the t flag sorts contents from newest to oldest. r flag does the reverse. Check out other flags by typing-in man ls |
ll | Shortcut for ls -l. Note that this doesn't always work |
cd | Change directory, goes to the /root/ directory |
cd ~ | Goes to the root directory |
cd directory-name | Goes to the directory selected. Change the directory-name to desired directory. |
cd .. | Goes one-level up. Returns to previous directory. |
Text Files: Creating and Editing
Commands | Description |
---|---|
touch file-name | Creates a text file. Change file-name. |
echo text | Prints text onto the screen, doesn't create a file |
echo text > file-name | Doesn't print the text but instead redirect it to a new file called file-name. Note that file-name is now created. |
cat file-name | Display contents of text file |
echo new-text > file-name | Redirects new-text to file-name. Note that when using redirect, it replaces the entire content. |
echo newer-text >> file-name | Appends newer-text at the end of the content of file-name |
vi file-name | Edit file-name through vi |
vim file-name | Edit file-name through vi improved |
nano file-name | Edit file-name through nano |