linux Flashcards
What is the root directory? What is the command to go there?
It’s the most base directory that contains literally everything else on the machine
cd /
What does this command do?
cd /
Go to root directory
How do you go to your home directory?
cd
OR
cd ~
What does this command do?
cd
Go to home directory
What does this command do?
cd ~
Go to home directory
How do you go to parent directory?
cd ..
What does this command do?
cd ..
Go to parent directory
command for creating a folder
mkdir /some/directory
Command to output a literal/string
echo “some_string”
Command to write output to file
echo “some_string” > filename.txt # overwrites
echo “some_string”»_space; filename.txt # appends
Commands to view contents of a file and then exit viewing mode
cat filename
OR
less filename
q to quit viewing mode
Commands to copy, move, or delete? Same for files and folders or different?
cp to copy
mv to move
rm to delete (files only)
rmdir to delete (empty folders only)
How do you rename a file or folder?
mv path path_renamed
How to count words or lines in a file?
wc file_name # words
wc -l file_name # lines
How to count the numbers of files in a folder?
ls folder_path | wc -l
the pipe input lists the files, one on each line; the pipe output counts the # of lines