| Command | Description | Example |
|---|---|---|
clear |
Clear terminal | clear |
history |
Show history | history |
pwd |
Show working directory | pwd |
cd |
Change directory | cd <directory> |
cd |
Change directory to a multilevel path | cd <directory>/<sub_directory> |
cd |
Change directory to your home directory | cd ~ |
cd |
Change directory to the parent directory | cd .. |
ls |
List directories and files | ls <directory> |
ls |
List all directories and files (even hidden) | ls -a |
ls |
List directories and files recursively | ls -R |
ls |
Show more information for ls |
ls -lt |
mkdir |
Create directory | mkdir <directory> |
touch |
Create file | touch <file> |
echo |
Write in file (overwrite) | echo "<text>" > <file> |
echo |
Write in file (append) | echo "<text>" >> <file> |
cat |
Show content of a file | cat <file> |
cat |
Show content of multiple files | cat <file1> <file2> |
head |
Show the first 10 lines | head <file> |
tail |
Show the last 10 lines | tail <file> |
cp |
Copy file | cp <file_source> <file_destination> |
cp |
Copy directory | cp -R <directory_source> <directory_destination> |
mv |
Move file | mv <file_source> <file_destination> |
rm |
Remove file | rm <file> |
rm |
Remove multiple files | rm <file1> <file2> |
rm |
Remove directory and its content | rm -R <directory> |
rmdir |
Remove empty di# rectory | rmdir <directory> |
code |
Open file in VSCode | code <file> |
code |
Open current directory in VSCode | code . |
Use --help to see more information.
<command> --help
<command>is the name of the command you want to see more information about.
Note
Using Linux or MacOS? You can also use man <command> to see the manual page of this command.
Use cd to move to the named directory.
cd <directory>
<directory>is the name of the directory you want to move to.
cd ~cd ..cd <directory>/<sub_directory>
<directory>/<sub_directory>is the path of the sub directory you want to move to.
Use ls to list directories and files in the current directory.
ls <options> <directory>
<options>and<directory>are optional.
ls -aUse ls -R to list directories and files in the current directory and its subdirectories.
ls -Rls -ltUse pwd to show the current working directory.
pwdUse pushd to go to an other directory but keep the current working directory in cache.
Use popd to return to the current working directory.
pushd <directory>
<directory>is the name of the directory you want to go to.
popdUse mkdir to create a new directory.
Tip
mkdir -v will print the name of each created directory.
mkdir <directory>
<directory>is the name of the directory you want to create.
mkdir <directory1>/<directory2>
<directory1>/<directory2>is the path of the sub directory you want to create.
mkdir <directory1> <directory2> ...
<directory1> <directory2> ...are the names of the directories you want to create.
Use cp -R to copy a directory.
cp acts like a copy/paste.
Tip
cp -R -v will print the name of each copied directory.
cp -R <directory_source> <directory_destination>
<directory_source>is the name of the directory you want to copy.<directory_destination>is the name of the directory you want to copy to.-Ris used to copy a directory recursively.
Use mv to move a directory.
mv acts like a cut/paste.
Tip
mv -v will print the name of each moved directory.
mv <directory_source> <directory_destination>
<directory_source>is the name of the directory you want to move.<directory_destination>is the name of the directory you want to move to.
Use mv to rename a directory.
Tip
mv -v will print the name of each renamed directory.
mv <directory_name> <directory_new_name>
<directory_name>is the name of the directory you want to rename.<directory_new_name>is the new name of the directory.
Use rm to delete a directory.
Tip
rm -v will print the name of each deleted directory.
Use rmdir to delete an empty directory.
rmdir <directory>
<directory>is the name of the directory you want to delete.
Warning
Pay attention that rm -R will delete all the files and subdirectories in the directory.
rm -R <directory>
<directory>is the name of the directory you want to delete.
Use touch to create a new file.
touch <file>
<file>is the name of the file you want to create.
If you want to create multiple files, use touch <file1> <file2> ...
touch <file1> <file2> ...
<file1> <file2> ...are the names of the files you want to create.
Use echo to write in a file.
echo "<text>" > <file>
<text>is the text you want to write in the file.<file>is the name of the file you want to write in.
Warning
> will overwrite the content of the file.
echo "<text1>\n<text2>" > <file>
<text1>and<text2>are the text you want to write in the file.\nis used to add a new line.<file>is the name of the file you want to write in.
echo "<text>" >> <file>
<text>is the text you want to write in the file.<file>is the name of the file you want to write in.
Use cat to show the content of a file.
cat <file>
<file>is the name of the file you want to show.
head <file>
<file>is the name of the file you want to show.
tail <file>
<file>is the name of the file you want to show.
Use cp to copy a file.
Tip
cp -v will print the name of each copied file.
cp <file_source> <file_destination>
<file_source>is the name of the file you want to copy.<file_destination>is the name of the file you want to copy to.
Use mv to move a file.
Tip
mv -v will print the name of each moved file.
mv <file_source> <file_destination>
<file_source>is the name of the file you want to move.<file_destination>is the name of the file you want to move to.
mv *.<file_extension>
<file_extension>is the extension of the files you want to move.
Use mv to rename a file.
Tip
mv -v will print the name of each renamed file.
mv <file_name> <file_new_name>
<file_name>is the name of the file you want to rename.<file_new_name>is the new name of the file.
Use rm to delete a file.
Tip
rm -v will print the name of each deleted file.
rm <file>
<file>is the name of the file you want to delete.
rm <file1> <file2> ...
<file1> <file2> ...are the names of the files you want to delete.