Linux has a hundred useful commands for you can easily interact such as system, file, folder, network, etc.
In the following sections, we discuss all the Linux command line and how to efficiently use it in specific cases.
Command | Description | Example |
---|---|---|
man | Show manual for a command | man ssh |
ssh | Remote login client | ssh tets@192.168.1.1 [-p port_number] |
whoami | Who logged in | |
w | Display who is online | |
date | Show current date and time of system | |
free | Show memory and swap usage | |
df | Show disk usage | |
du | Show directory space usage | |
top | Display Linux processes | |
ctrl + c | Halts current command | |
ctrl + z | Stops current command | |
ctrl + t | Open new window in terminal | |
exit | Log out of current session | |
cd [dir] | Go to a directory | |
cd .. | Back to previous directory | |
cd | Go to home | |
pwd | Show the path of current directory | |
ls | List all things on a directory | |
ls -la | List all things on a directory include hidden files | |
touch myfile | Create or update a file | |
cat myfile | Output contents of file | |
head myfile | Output first default 10 lines of file | head -n 100 myfile |
tail myfile | Output last default 10 lines of file | tail -n 100 myfile |
cp myfile1 myfile2 | Copy myfile1 to myfile2 | |
mv myfile1 myfile2 | Rename myfile1 to myfile2 | |
tail -f myfile | Output contents of file as it grows | |
chmod | Change permission of file | |
rm [-f] | Remove a file | rm -f myfile |
mkdir mydir | Create a new directory | |
rm [-r] | Remove a directory | rm -rf mydir |
tar cf myfile.tar myfiles | Compress myfiles into myfile.tar | |
tar xf myfile.tar | Decompress myfile.tar into current directory | |
ps aux | Display currently active processes in detail | |
lsof -i:port_number | Find information of the app which is running on port_number | lsof -i:80 |
kill pid | Kill process with pid number | kill 381296 |
killall myapp | Kill all processes named myapp | |
ping host | Check connection to a host | ping google.com.vn |
wget [options] [url] | Download a file from url | wget https://cdn.kernel.org/pub/linux/kernel/v4.x/linux-4.17.2.tar.xz |