1/30
Looks like no tags are added yet.
Name | Mastery | Learn | Test | Matching | Spaced |
---|
No study sessions yet.
What command prints the current working directory?
pwd
How do we change directory?
cd
How do you change to the parent directory?
cd ..
How do you change to the home directory quickly?
cd ~ or just cd
What’s the difference between an absolute and relative path?
Absolute starts at root /; relative starts from your current pwd
Create a new directory called project
.
mkdir project
Create an empty file called notes.txt
.
touch notes.txt
Copy file.txt
to backup.txt
.
cp file.txt backup.txt
Copy a directory and its contents.
cp -r dir1 dir2
Rename old.txt
to new.txt
.
mv old.txt new.txt
Move report.txt
into the docs/
directory.
mv report.txt docs/
Delete file.txt
.
rm file.txt
Delete a directory and everything inside it.
rm -r dirname
Safely delete interactively (prompt before delete).
rm -ri dirname
List all files in current directory
ls
Show hidden files too
ls -a
View a file’s contents at once.
cat file.txt
View a long file one page at a time.
less file.txt
How do you clear the terminal?
clear
Search for “error” in log.txt
.
grep "error" log.txt
Case-insensitive search for “error” in log.txt
grep -i "error" log.txt
Find all .txt
files in current directory and subdirectories.
find . -name "*.txt"
Pipe output of ls
into grep
to find .py
files.
ls | grep ".py"
Show all recently run commands
history
Search history for “grep”.
history | grep grep
Append “hello” to notes.txt
without overwriting.
echo "hello" >> notes.txt
Save output of ls
into list.txt
, replacing existing file.
ls > list.txt
What is the root directory called?
/
What is the single dot .
in a directory?
A link to the current directory.
What is the double dot ..
in a directory?
A link to the parent directory
Show a directory tree structure visually.
tree