Command Line Flashcards
What is $echo ?
It repeats the argument you type in with a new trailing newline character
What does the flag in $echo -n mean?
No new trailing newline character for the echo command
e.g. $echo Hello World => Hello World => $ e.g. $echo -n Hello World =>Hello World $
Does $echo “Hello World” -n works to eliminate new trailing newline character?
No. Flag always comes before arguments.
What does it mean:
$cd /
Change directory to ROOT directory.
NOTE: there’s a space in front of “/”
How to go back to your home directory in CLI?
$cd ~
What does it mean:
$pwd
It shows you your current directory is at.
pwd = Print Working Directory
What does it mean:
$ls
It shows you the files and directory under your current directory
ls = LiSt directory
What does it mean:
$ mkdir This is good
It creates a new directory under the directory you’re at
** You should name the new directory in the arguments
mkdir = Make Directory
What does it mean:
$touch abc.txt
This command creates a new file (*not directory) in the current directory
** type the file name and its file type in the arguments
abc.txt = a text file named “abc”
How to rename a file (named “toy.txt”)?
$ mv toy.txt toy2.txt
How does the pattern of $ mv works?
$ mv [source] [destination]
1) if you want to change the file name, determine the source file name and write the new name in destination.
2) if you want to move a file to another directory - specify you source file name and write the destined directory in the destination (**it does not apply to move from a subdirectory back to parent directory, see point 3) (file directory needs to have slash behind file name, e.g. tmp/)
3) You can even take a file in a directory under your current directory back to your current directory; and then rename it (if you only move and no rename, still need to type in the original name).
e.g. $ mv tmp/example1.txt example2.txt
$ mv tmp/example1.txt example1.txt
How to go back to the parent directory?
$ cd ..
.. = two dots
How to remove a file (e.g. “abc.txt”)?
$ rm abc.txt
How to remove a directory (e.g. “Tealeaf”)
$ rm -r Tealeaf
*Remember to add the flag -r for recursive delete of a directory; it’s different from just deleting a file.
How to exit from content listing command like $ man or $ less ?
type q