Ubuntu common instructions and usage details

  1. ls

This is equivalent to the dir command under Windows, which can list the contents of the current window or the specified window.

  1. rm

This is equivalent to the del and rmdir commands under Windows, which can delete files and folders.

Common usage: rm -rf/home/ubuntu/.cache (delete the folder /home/ubuntu/.cache)

Taboo: rm-rf /* This command will delete all files in the root partition. On some efi machines, it will also delete the motherboard firmware, causing the motherboard firmware to be lost and unable to boot (more serious than the operating system failure).

  1. chmod

Changing file permissions is similar to the security tab of file properties under Windows.

Common usage: chmod-R 777 /home/ubuntu/example (change the directory and all files in it to 777 permissions (777 permissions mean anyone can modify the content)).

Taboo: chmod-R 777 /etc

chmod-R 777 /

( The root partition and /etc are critical parts of the system, and changing permissions will cause the system to fail to start)

  1. apt、apt-get

This is similar to the dism command of Win7/8/10, which is the package manager of the Debian series, which can install, update, and uninstall software. Most operations require root privileges

Common usage: apt-get update (update software source cache)

apt-getupgrade (update system)

apt-getdist-upgrade (Update system version)

apt-getinstall zhcon (install the software named zhcon)

apt-getremove zhcon (uninstall the software named zhcon)

Taboo: Uninstall key software packages, such as coreutils

  1. dpkg

Software installer.

Common usage: dpkg -i package path and name.

Note: Some software packages will report an error after installation, prompting lack of dependencies. At this time, you need to enter sudo apt-get -finstall again to repair dependencies. (If you want to save trouble, you can install gdebi, which is a graphical package installer, and it can automatically complete dependencies)

  1. tar

tar compression and decompression commands. To compress and decompress tar.lz, you need to install the lzip software package.

Common usage: tar-xf /home/ubuntu/coreutils-8.29.tar.xz (decompress this compressed package to the current directory)

tar-xvf /home/ubuntu/coreutils-8.29.tar.xz (decompress this compressed package to the current directory and display detailed information)

tar-xf /home/ubuntu/coreutils-8.29.tar.xz /home/ubuntu/gnu (decompress this compressed package to the /home/ubuntu/gnu directory)

tar-cvjpf etc.tar.bz2 /etc (-c is to create a packaged file, the corresponding -f is followed by the name of the created file, using the suffix of .tar.bz2, the -j flag is compressed using bzip2, and the last is specific Operation object /etc directory)

tar-cvzpf etc.tar.gz /etc (-c is to create a packaged file, the corresponding -f is followed by the name of the created file, using the .tar.gz suffix, the -z flag is compressed using gzip, and the last is specific Operation object /etc directory)

  1. vi、nano

These are two editors. The latter is recommended if simple text editing is required.

  1. sudo、su

sudo is to make this command run in the root state, but use the user configuration of the current user.

Common usage: sudoapt-get update (update software source cache, this command requires root privileges)

sudo-s (switch to root privileges, but use the user configuration of the current user)

su can achieve the above functions, but will load the configuration of the specified user.

Common usage: su (switch to the root user and load the user configuration of that user)

su123 (switch to 123 and load the user configuration of that user)

su-c "apt-get update", switch to the root user and update the software source cache.

  1. fsck

Disk check and repair commands can check and repair file system errors. Similar to chkdsk under Windows. However, the "partition" to be entered here is not the directory after the partition is mounted, but the identifier of the partition in /dev.

Common usage: fsck/dev/sda1 (check and repair /dev/sda1 partition)

  1. zhcon

This is a Chinese plug-in for tty, similar to the Tianhui Chinese character system in the DOS era.

Since tty will be garbled in Chinese mode in Ubuntu, it can be solved by using zhcon.

Common usage: zhcon–utf8 (Run zhcon in utf-8 mode. Generally, the parameter –utf8 is required when running zhcon).

zhcon may not be pre-installed, please manually enter sudoapt-get install zhcon to install it.

  1. make

Compile command, the specific parameters depend on your makefile configuration

If you need to use multi-threaded compilation, you can add -j <thread number> to the parameter to compile.

For example, my processor has four cores and eight threads, so I can type make -j8 to compile, which will be much faster.

  1. gcc

GCC compiler, the specific parameters depend on your needs.

  1. dd

This command can fill the corresponding content into the file.

Common usage: ddif=/home/ubuntu/ubuntu.iso of=/dev/sdc (write the content of ubuntu.iso to /dev/sdc)

Taboo: ddif=/dev/zero of=/dev/sda This command will clear the main hard disk, causing the system to fail to boot and data recovery.

  1. cfdisk

Disk management tools can manage disk partitions and disk image files in raw format.

  1. whereis

This is a query tool that can query specified files.

Common usage: whereisbash (query where is the program bash)

  1. touch

Create empty file

Common usage: touchupdate.sh (create an empty update.sh file)

  1. alias

Set the command alias.

Common usage: aliasdir ='ls' (set dir as the alias of ls)

  1. pkill

End the process, similar to the taskkill command under Windows

Common usage: pkillbash (end bash process)

  1. uname

Display information such as Linux version and system architecture.

Common usage: uname-r displays the Linux kernel version number.

uname-ar show all version information

uname-m displays the current system architecture

  1. sync

Write the changes to disk. Since Linux has a delayed write function (in order to enhance performance), it does not synchronize the content to the disk immediately after performing some operations.

To be on the safe side, for example, if your power supply is unstable, you may encounter a power failure. Please enter the sync command regularly to prevent accidents.

In addition, the system will automatically execute the sync command before shutting down and restarting, so if you are about to shut down or restart, you do not need the sync command.

Common usage: sync to synchronize the current user's data

Run sync as root: synchronize all user data.

to sum up

The above is a detailed explanation of common Ubuntu commands and usage introduced by the editor. I hope it will be helpful to you. If you have any questions, please leave me a message. The editor will reply to you in time. Thank you very much for your support to the ZaLou.Cn website!

Recommended Posts

Ubuntu common instructions and usage details
Installation and usage instructions of rz/sz command under ubuntu
Install docker on ubuntu and basic usage
Ubuntu common commands
ubuntu 1804 installation details
Installation of pulseaudio and API usage under Ubuntu 12.04
Basic configuration and common software installation after ubuntu 18.04 installation
Summary: Ubuntu Python2.x and
Ubuntu20.04 experience and beautification
Ubuntu introduction and installation
023. Ubuntu common personalized configuration
Common exceptions and solutions for Ubuntu system installation and configuration
Ubuntu backup and restore
Summary of ubuntu usage
ubuntu16.04 build vim and pyt
Ubuntu 16.04 compile and install PHP 7.2
ubuntu18.04 compile and install python3.8
Ubuntu16.04 installation and simple configuration
Jmeter (18)_Ubuntu deploy jmeter and ant
ubuntu install and configure GitLab
Ubuntu deployment and experience Nexus3
CentOS common exceptions and solutions
Install common software on Ubuntu 16.04
ubuntu builds common development environment
Ubuntu16.04 install SVN and configuration
Ubuntu16.04 install and uninstall VMware-Workstation 14
Ubuntu PostgreSQL installation and configuration
Common exceptions and solutions in the use and development of Ubuntu system