Skip to main content

Commands Cheatsheet

Updated Feb 24, 2021 ·

Directory

CommandsDescription
pwdDisplays the current directory
ls Lists the contents of a directory
ls -laLists the contents but also shows permissions, user, group, size, and date/time created.
ls -latrSimilar 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
llShortcut for ls -l. Note that this doesn't always work
cdChange directory, goes to the /root/ directory
cd ~Goes to the root directory
cd directory-nameGoes 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

CommandsDescription
touch file-nameCreates a text file. Change file-name.
echo textPrints 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-nameDisplay contents of text file
echo new-text > file-nameRedirects new-text to file-name. Note that when using redirect, it replaces the entire content.
echo newer-text >> file-nameAppends newer-text at the end of the content of file-name
vi file-nameEdit file-name through vi
vim file-nameEdit file-name through vi improved
nano file-nameEdit file-name through nano