I'm in and out of server boxes all day using terminals and screen sessions. Making edits to files, setting up cron jobs, creating docker containers and monitoring data pipelines. Below are the top 5 commands I use every day.
1
cd
and cd ..
Navigate to a directory
cd MyFolder
Navigate back a directory relative to your current path. If current path is
/home/user/MyFolder
executingcd ..
will bring you to/home/user
2
ls
and ls -ls -h
- List all contents in current path.
ls
executed while on path./MyDirectory
will listmain.py
,profile_pic.jpg
andcreds.txt
├── MyDirectory
│ ├── main.py
│ └── profile_pic.jpg
└── creds.txt
- List all contents and it's attributes in current path AND in human-readable (
-h)
format. ie.main.py
is 903 bytes in size usingls -ls -h
-rw-rw-r-- 1 adam adam 0 Dec 20 09:49 creds.txt
-rw-rw-r-- 1 adam adam 903 Dec 20 09:49 main.py
-rw-rw-r-- 1 adam adam 0 Dec 20 09:49 profile_pic.jpg
3
pwd
- Prints the full name of the path in the current working directory.
pwd
while inMyDirectory
would hypothetically print/home/user/MyDirectory/
4
nano
- nano is a terminal file editor, nano does not always come pre-installed with every flavor of Linux. To create and start to edit a brand new text file:
nano main.py
will create a file called main.py and bring you right into the text editor.
5
cp
Copy a single file.
cp <source> <destinationpath_and_filename>
To copy
main.py
and place it in the same directorycp main.py main_copy.py
To copy
main.py
to a new directory, first create the directorymkdir NewFolder
and copy main into itmain.py NewFolder/main_copy.py