ITZone

29 The Linux command requires you to know

All Linux distributions have user interface support to interact with the computer. However, in some cases, using the command line interface to control the computer will be faster and simpler.

In the command line interface, the commands are used to instruct the computer to perform a certain task. You can use the command to turn off the computer, view the list of files in the directory, copy files, move and delete files, etc.

Below I will list common Linux commands so that new Linux users or Linux administrators can easily learn and look up.

1. ls – List

ls lists content (files and directories) in the current directory. It is similar to opening a folder and viewing content in it on the user interface.

2. mkdir – Make Directory

mkdir <new folder name> create a new folder. It is similar to choosing new / create directory to create a new directory on the user interface.

3. pwd – Print Working Directory

pwd prints the full path to the current directory.

4. cd – Change Directory

cd <directory> converts a directory into the current directory for the current session. It is similar to opening a folder and manipulating the files and folders within that user interface.

5. rmdir – Remove Directory

rmdir <directory> delete a directory.

6. rm – Remove

rm <file name> delete file. You can also use rm -r <directory name> to delete directories and all data in that directory.

7. cp – Copy

cp <source file> <file destination> copy the file from the source location to the destination location.
You can also use cp -r <source directory> <target directory> to copy the directory and all internal data.

8. mv – Move

mv <source> <target> move a file or folder from one location to another. This command is also used to rename files or folders if <source> and <target> are the same folder.

9. cat – concatenate and print files

cat <file name> read and print the contents of the file to the screen.

10. tail – print TAIL

tail <file name> read and print the last 10 lines of the file (default).
You can use tail -n N <file name> to specify the N lines to print to the screen.

11. less – print LESS

less <file name> prints the contents of a file by page in case the file content is too large and must be read by the page. You can use Ctrl + F to move the next page and Ctrl + B to move to the previous page.

12. grep

grep <string> <file name> searches the content of the file according to the supply chain.
You can use grep -i <string> <filename> to search for non-case sensitive or grep -r <string> <directory name> to search the entire directory

13. find

find <> directory -name <file name> search file in <directory> under <file name> .
You can also use find <directory> -iname <filename> to search regardless of regular flowers.

14. tar

tar -cvf <name-file-compress.tar> <file1 or file2 …> create compressed file (.tar) from the available files.

tar -tvf <name-file-compressed.tar> see the compressed file content (.tar).

tar -xvf <name-file- compressed.tar > extract (.tar file).

15. gzip

gzip <file name> create compressed file (.gz). Use gzip -d <file name> to extract (.gz file).

16. unzip

unzip <file-zipped.zip> unzip a compressed file (.zip). Use unzip -l <file-compressed.zip> to view zip file contents without extracting.

17. help

<> -help statement see the help information and command options.
Can be abbreviated as <statement> -h

18. whatis – What is this command

whatis <command name> shows a description of the command.

19. man – Manual

man <command name> displays the instruction page for the command.

20. exit

exit exit the session. Similar to exiting an application on the user interface.

21. ping

ping <host> address to ping a remote host (server) by sending packets to that host. It is often used to check the network connection to the server.

22. who – Who Is logged in

who displays the list of accounts logged into the system.

23. su – Switch User

su <account name> switch to login with another account. The root account can switch to login with other accounts without entering a password.

24. uname

uname shows some system information such as kernel name, host name, processor, …
You can use the uname -a command to display all information.

25. free – Free memory

free view memory information: used memory, free memory on the system
You can use the free -m command to see the memory with KBs units or free -g to view with GBs

26. df – Disk space Free

df view information about hard disk capacity (used, available, …) and other storage devices.
You can use the df -h command to view information in human readable form (displayed in KBs units, GBs for readability).

27. ps – Processes

ps displays information about running processes.

28. top – Top processes

The top displays information about running processes, sorted by CPU performance.
You can also use the top -u command <account> to view the running process information for that account.

29. shutdown

shutdown command to turn off the computer. You can use shutdown -r to restart the computer.

ITZone via Techmaster

Share the news now