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
How can you tell if a folder or file path is relative or absolute?
Absolute paths START with a “/”; relative paths don’t.
How do you look up details about a command right in the terminal?
man whatever_command # man stands for manual
How do you create or find a hidden file?
All hidden filenames start with a “.”
How do you run a command as a superuser from your regular user account?
sudo
What’s the “curl” command in shell?
Used to interface with a URL (hence the “url” part of “curl”)