- Cd
The CD is the command that enters the Linux system directory folder, the absolute path and the relative path that can be entered
Cd/home Enter '/home ' directory '
Cd.. Return to the top level directory
Cd.. /.. Return to the top level two directory
CD into the personal home directory
CD ~user1 into the personal home directory
CD-Return to the last directory
- Pwd
Show current work path
- Ls
View files in the directory ll is equivalent to Ls–l
ls to view the files in the directory
Ls-f viewing files in a directory
Ls-l displaying details of files and directories
Ls-a Show hidden files
LS *[0-9]* displays filenames and directory names that contain numbers
- Mkdir
Create a directory,-p even if the directory below the path does not exist, it will automatically create
mkdir dir1 Create a directory called ' Dir1 '
mkdir dir1 DIR2 Create two directories at a time
Mkdir-p/tmp/dir1/dir2 Create a directory tree
- Touch
Create a file
- Rm
Deleting files and directories,-r means containing subdirectories, and-f means forcing
Rm-f file1 Delete a file called ' File1 '
RmDir dir1 Delete a directory called ' Dir1 '
RM-RF Dir1 Delete a directory called ' Dir1 ' and delete its contents at the same time
RM-RF dir1 DIR2 Delete two directories and their contents at the same time
- Mv
Move files or make changes to file names using
MV Dir1 New_dir Renaming/Moving a directory
- Cp
Copy copy files/folders and modify file names
CP file1 file2 Copy a file
CP dir/*. Copy all files under a directory to the current working directory
Cp-a/tmp/dir1. Copy a directory to the current working directory
Cp-a dir1 dir2 Copy a directory
- Cat
Cat File1 Viewing the contents of a file starting from the first byte
- Head
View file contents in the past
Head-n File1 View the first n rows of a file
- Tail
View file contents from forward to back
Tail-n File1 View the last n rows of a file
Tail-f/var/log/boot.log Real-time view of content that is added to a file
- More
More File1 View the contents of a long file, unlike cat (show All), more is paginated display
- Find
Find/-name file1 from '/' to the root file system to search for files and directories
Find/-user User1 search for files and directories belonging to user ' User1 '
Find/home/user1-name \*.bin in directory '/home/user1 ' search for files with '. Bin '
Find/usr/bin-type f-atime +100 Search execution files that have not been used in the last 100 days
Find/usr/bin-type f-mtime-10 search for files created or modified within 10 days
Find/-name \*.rpm-exec chmod 755 ' {} '; Search for files ending with '. RPM ' and define their permissions
Find/-xdev-name \*.rpm search for files ending with '. RPM ', ignoring removable devices such as optical drives, Czech disks, etc.
- Ifconfig
Display Ethernet Card Information
- Mount
Attach the external device to the system
Mount/dev/cdrom/mnt/cdrom mount a CDROM or dvdrom
- Umount
Umount/dev/cdrom uninstalling an external device that is already hanging on
- Df
DF-H displays a list of the partitions that are already mounted
- Du
Du-sh dir1 estimate directory ' Dir1 ' already used disk space '
Du-sk * | SORT-RN display the size of files and directories in terms of capacity size
- Useradd
Useradd User1 create a new user
- Groupadd
Groupadd group_name Create a new user group
- chmod
chmod ugo+rwx Directory1 Set directory owner (U), Group (g), and others (O) to read (R), write (w), and execute (x) permissions
chmod go-rwx directory1 Delete Group (g) Read and write execution permissions on the directory with others (O)
- Chown
Chown user1 File1 Change the Owner property of a file
Chown-r User1 Directory1 Change the owner property of a directory and change the properties of all files in the directory at the same time
- Tar
TAR-CVF Archive.tar File1 Create a non-compressed tarball
TAR-CVF Archive.tar file1 file2 dir1 Create a file containing ' file1 ', ' file2 ' and ' Dir1 '
TAR-TF Archive.tar Display the contents of a package
TAR-XVF Archive.tar Release a package
TAR-XVF ARCHIVE.TAR-C/TMP releases the compressed package into the/tmp directory
TAR-CVFJ archive.tar.bz2 Dir1 Create a compressed package in BZIP2 format
TAR-XVFJ archive.tar.bz2 extract a compressed package in BZIP2 format
TAR-CVFZ archive.tar.gz Dir1 Create a zipped package in gzip format
TAR-XVFZ archive.tar.gz Unzip a compressed package in gzip format
- Rpm
RPM-IVH package.rpm Installing an RPM package
RPM-IVH--nodeeps package.rpm Install an RPM package and ignore dependency warnings
Rpm-u package.rpm Update a RPM package without changing its configuration file
Rpm-f package.rpm update one to determine which RPM package is installed
Rpm-e package_name.rpm Delete an RPM package
RPM-QA display all installed RPM packages in the system
Rpm-qa | grep httpd shows all RPM packages with the words "httpd" in their names
Rpm-qi Package_name get special information for an installed package
RPM-QG "System environment/daemons" shows the RPM package for a component
RPM-QL Package_name displays a list of files provided by an already installed RPM package
RPM-QC Package_name Displays a list of configuration files provided by an already installed RPM package
Rpm-q package_name--whatrequires shows a list of dependencies that exist with a RPM package
Rpm-q package_name--whatprovides shows the volume of a RPM package
Rpm-q package_name--scripts Show scripts executed during installation/removal L
Rpm-q package_name--changelog shows the revision history of a RPM package
rpm-qf/etc/httpd/conf/httpd.conf confirm which RPM package is provided for the given file
RPM-QP package.rpm-l displays a list of files provided by a RPM package that has not been installed
RPM--import/media/cdrom/rpm-gpg-key Import Public key digital certificate
RPM--checksig package.rpm confirming the integrity of a RPM package
RPM-QA Gpg-pubkey confirm the integrity of all RPM packages that have been installed
Rpm-v package_name Check file size, license, type, owner, group, MD5 check, and last modified time
Rpm-va Check all installed RPM packages in the system-use with care
RPM-VP package.rpm confirm that an RPM package is not installed
Rpm2cpio package.rpm | Cpio--extract--make-directories *bin* Run executable from an RPM package
rpm-ivh/usr/src/redhat/rpms/' arch '/package.rpm install a built-in package from a RPM source
Rpmbuild--rebuild package_name.src.rpm Build a RPM package from one RPM source
- Yum
Yum install package_name download and install a RPM package
Yum Localinstall package_name.rpm will install a RPM package and use your own software repository to resolve all dependencies for you
Yum Update package_name.rpm updates all installed RPM packages in the current system
Yum Update package_name updates a RPM package
Yum Remove package_name Delete an RPM package
Yum list lists all packages installed in the current system
Yum search package_name searching for packages in RPM repositories
Yum Clean Packages cleanup rpm cache to delete downloaded packages
Yum Clean headers Delete all header files
Yum Clean all deletes all cached packages and header files
- Grep
grep aug/var/log/messages Find the keyword "/var/log/boot.log" in the file '
grep ^aug/var/log/messages in file '/var/log/boot.log ' to find words that begin with "."
grep [0-9]/var/log/messages selects all rows in the '/var/log/boot.log ' file that contain numbers
grep aug-r/var/log/* searches the directory '/var/log ' and subsequent directories for the string "the"
- File
View File types
- which
Find execution Command file location
- Whereis
Find File storage Path
- Init
Switching execution levels, Linux has seven levels of execution:
--run Level 0: Shutdown
--run Level 3: Plain text mode
--run Level 5: Graphics interface mode included
--run Level 6: Restart
Use the init command to switch between the modes. If you want to shut down, you can also use the following instructions to power off the shutdown-h now and Poweroff.
30 common commands for Linux learning