In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-01-21 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Servers >
Share
Shulou(Shulou.com)05/31 Report--
This article is to share with you about the common commands in Linux. The editor thinks it is very practical, so share it with you as a reference and follow the editor to have a look.
1. System information
Processor architecture of arch display machine
Processor Architecture of uname-m display Machine
Uname-r shows the kernel version in use
Dmidecode-Q display hardware system components-(SMBIOS / DMI)
Hdparm-I / dev/hda lists the architectural features of a disk
Hdparm-tT / dev/sda performs testable read operations on disk
Cat / proc/cpuinfo displays the information of CPU info
Cat / proc/interrupts display interrupt
Cat / proc/meminfo verifies memory usage
Cat / proc/swaps shows which swap is used
Cat / proc/version shows the kernel version
Cat / proc/net/dev display Network Adapter and Statistics
Cat / proc/mounts displays the loaded file system
Lspci-tv lists PCI devices
Lsusb-tv display USB device
Date displays the system date
Cal 2007 displays the calendar for 2007
Date 041217002007.00 sets the date and time-month, day, hour, year. Second
Clock-w saves time changes to BIOS
2. Shutdown (shutdown, restart and logout of the system)
Shutdown-h now shuts down the system
Init 0 shuts down the system
Telinit 0 shuts down the system
Shutdown-h hours:minutes & shuts down the system at the scheduled time
Shutdown-c cancels shutting down the system at the scheduled time
Shutdown-r now restart
Reboot restart
Logout logout
3. Files and directories
Cd / home enter the'/ home' directory'
Cd.. Return to the previous directory
Cd.. /.. Return to the upper two-level directory
Cd enters the personal home directory
Cd ~ user1 enters the personal home directory
Cd-returns the directory where it was last located
Pwd displays the work path
Ls view the files in the directory
Ls-F View the files in the directory
Ls-l displays the details of files and directories
Ls-a shows hidden files
Ls * [0-9] * displays file and directory names that contain numbers
Tree displays the tree structure of files and directories starting from the root directory
Lstree displays the tree structure of files and directories starting from the root directory
Mkdir dir1 creates a directory called 'dir1''
Mkdir dir1 dir2 creates two directories at the same time
Mkdir-p / tmp/dir1/dir2 create a directory tree
Rm-f file1 deletes a file called 'file1''
Rmdir dir1 deletes a directory called 'dir1''
Rm-rf dir1 deletes a directory called 'dir1' and deletes its contents at the same time
Rm-rf dir1 dir2 deletes both directories and their contents
Mv dir1 new_dir rename / move a directory
Cp file1 file2 copies a file
Cp dir/*. Copy all files in 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
Ln-s file1 lnk1 creates a soft link to a file or directory
Ln file1 lnk1 creates a physical link to a file or directory
Touch-t 0712250000 file1 modifies the timestamp of a file or directory
4. File search
Find /-name file1 enters the root file system from'/'to search for files and directories
Find /-user user1 searches for files and directories belonging to user 'user1'
Find / home/user1-name\ * .bin searches for files ending with '.bin' in the directory'/ home/user1''
Find / usr/bin-type f-atime + 100 searches for execution files that have not been used in the past 100 days
Find / usr/bin-type f-mtime-10 searches for files that have been created or modified within 10 days
Find /-name\ * .rpm-chmod 755'{}'\; search for files ending with '.rpm' and define their permissions
Find /-xdev-name\ * .rpm searches for files ending in '.rpm' and ignores removable devices such as CD-ROMs and Agile drives
Locate\ * .ps looks for files that end with '.ps'-run the 'db' command first
Whereis halt shows the location of a binary, source, or man
Which halt displays the full path to a binary or executable file
5. Mount a file system
Mount / dev/hda2 / mnt/hda2 mount a disk called hda2-make sure the directory'/ mnt/hda2' already exists
Umount / dev/hda2 unmount a disk called hda2-exit from mount point'/ mnt/hda2' first
Fuser-km / mnt/hda2 force uninstall when the device is busy
Umount-n / mnt/hda2 runs the uninstall operation without writing to the / etc/mtab file-useful when the file is read-only or when the disk is full
Mount / dev/fd0 / mnt/floppy mount a floppy disk
Mount / dev/cdrom / mnt/cdrom mount a cdrom or dvdrom
Mount / dev/hdc / mnt/cdrecorder mount a cdrw or dvdrom
Mount / dev/hdb / mnt/cdrecorder mount a cdrw or dvdrom
Mount-o loop file.iso / mnt/cdrom mounts a file or ISO image file
Mount-t vfat / dev/hda5 / mnt/hda5 mounts a Windows FAT32 file system
Mount / dev/sda1 / mnt/usbdisk mounts a usb shortcut or flash memory device
Mount-t smbfs-o username=user,password=pass / / WinClient/share / mnt/share mounts a windows network share
6. Disk space
Df-h displays a list of mounted partitions
Ls-lSr | more arranges files and directories by size
Du-sh dir1 estimates the directory 'disk space already used by dir1''
Du-sk * | sort-rn displays the size of files and directories in turn based on capacity
Rpm-Q-a-- qf'{SIZE} t% {NAME} n' | sort-K1Power1n displays the space used by installed rpm packages in turn based on size (fedora, redhat systems)
Dpkg-query-W-fallow packages ${Installed-Size;10} t ${Package} n' | sort-K1Magin1n displays the space used by installed deb packages based on size (ubuntu, debian systems)
7. Users and groups
Groupadd group_name creates a new user group
Groupdel group_name deletes a user group
Groupmod-n new_group_name old_group_name rename a user group
Useradd-c "Name Surname"-g admin-d / home/user1-s / bin/bash user1 creates a user belonging to the "admin" user group
Useradd user1 creates a new user
Userdel-r user1 deletes a user ('- r 'excludes home directory)
Usermod-c "User FTP"-g system-d / ftp/user1-s / bin/nologin user1 modify user attributes
Passwd change password
Passwd user1 modifies a user's password (only root is allowed to execute)
Chage-E 2005-12-31 user1 sets the expiration period for user passwords
Pwck checks the file format and syntax correction of'/ etc/passwd''as well as the presence of users
Grpck checks the file format and syntax correction of'/ etc/passwd''as well as existing groups
Newgrp group_name logs in to a new group to change the default group of newly created files
8. File permissions-use "+" to set permissions and "-" to cancel
Ls-lh display permissions
Ls / tmp | pr-T5-W$COLUMNS divides the terminal into 5 columns for display
Chmod ugo+rwx directory1 sets permissions for directory owners (u), groups (g), and others (o) to read (r), write (w), and execute (x)
Chmod go-rwx directory1 deletes group (g) and others (o) read and write permissions to the directory
Chown user1 file1 changes the owner property of a file
Chown-R user1 directory1 changes the owner properties of a directory and simultaneously changes the properties of all files in the directory
Chgrp group1 file1 changes the group of files
Chown user1:group1 file1 changes the owner and group properties of a file
Find /-perm-Utility lists all the files in a system that are controlled by SUID
Chmod Utility / bin/file1 sets the SUID bit of a binary file-the user running the file is also given the same permissions as the owner
Chmod Umurs / bin/file1 disables the SUID bit of a binary file
Chmod genders / home/public sets the SGID bit of a directory-similar to SUID, but for directories
Chmod Gmurs / home/public disables the SGID bit of a directory
Chmod STIKY / home/public sets the STIKY bit of a file-only legitimate owners are allowed to delete the file
Chmod Omurt / home/public disables the STIKY bit of a directory
9. Special properties of the file-use "+" to set permissions and "-" to cancel
Chattr + a file1 only allows you to read and write files as appends.
Chattr + c file1 allows this file to be automatically compressed / decompressed by the kernel
When chattr + d file1 makes a file system backup, the dump program will ignore this file
Chattr + I file1 is set to an immutable file and cannot be deleted, modified, renamed, or linked
Chattr + s file1 allows a file to be safely deleted
Once the chattr + S file1 application performs a write operation on this file, the system immediately writes the modified result to disk.
Chattr + u file1 if the file is deleted, the system will allow you to restore the deleted file later
Lsattr displays special properties
10. Package and compress files
Bunzip2 file1.bz2 unzips a file called file1.bz2'
Bzip2 file1 compresses a file called 'file1'
Gunzip file1.gz unzips a file called file1.gz'
Gzip file1 compresses a file called 'file1'
Gzip-9 file1 maximum compression
Rar a file1.rar test_file creates a package called 'file1.rar'
Rar a file1.rar file1 file2 dir1 compresses both 'file1',' file2' and directory 'dir1'
Rar x file1.rar decompress the rar package
Unrar x file1.rar decompress the rar package
Tar-cvf archive.tar file1 creates an uncompressed tarball
Tar-cvf archive.tar file1 file2 dir1 creates an archive file that contains' file1', 'file2' and' dir1'
Tar-tf archive.tar displays the contents of a package
Tar-xvf archive.tar releases a package
Tar-xvf archive.tar-C / tmp releases the package to the / tmp directory
Tar-cvfj archive.tar.bz2 dir1 creates a compressed package in bzip2 format
Tar-jxvf archive.tar.bz2 decompresses a compressed package in bzip2 format
Tar-cvfz archive.tar.gz dir1 creates a compressed package in gzip format
Tar-zxvf archive.tar.gz decompresses a compressed package in gzip format
Zip file1.zip file1 creates a compressed package in zip format
Zip-r file1.zip file1 file2 dir1 compresses several files and directories into a package in zip format at the same time
Unzip file1.zip decompresses a compressed package in zip format
11. RPM package-(Fedora, Redhat and similar systems)
Rpm-ivh package.rpm installs a rpm package
Rpm-ivh-nodeeps package.rpm installs a rpm package and ignores dependency warnings
Rpm-U package.rpm updates a rpm package without changing its configuration file
Rpm-F package.rpm updates a confirmed installed rpm package
Rpm-e package_name.rpm deletes a rpm package
Rpm-qa displays all installed rpm packages in the system
Rpm-qa | grep httpd displays all rpm packages with the word "httpd" in their names
Rpm-qi package_name gets special information about an installed package
Rpm-qg "System Environment/Daemons" displays the rpm package for a component
Rpm-ql package_name displays a list of files provided by the installed rpm package
Rpm-qc package_name displays a list of configuration files provided by the installed rpm package
Rpm-Q package_name-- whatrequires displays a list of dependencies on a rpm package
Rpm-Q package_name-- whatprovides shows the volume occupied by a rpm packet
Rpm-Q package_name-- scripts displays the script l executed during installation / removal
Rpm-Q package_name-- changelog displays the modification history of a rpm package
Rpm-qf / etc/httpd/conf/httpd.conf confirms which rpm package provided the given file
Rpm-qp package.rpm-l displays a list of files provided by an uninstalled rpm package
Rpm-- import / media/cdrom/RPM-GPG-KEY Import Public key Digital Certificate
Rpm-checksig package.rpm confirms the integrity of a rpm package
Rpm-qa gpg-pubkey confirms the integrity of all installed rpm packages
Rpm-V package_name checks file size, license, type, owner, group, MD5 check and last modification time
Rpm-Va checks all installed rpm packages in the system-use with caution
Rpm-Vp package.rpm confirms that a rpm package is not installed
Rpm2cpio package.rpm | cpio-- extract-- make-directories * bin* runs the executable file from a rpm package
Rpm-ivh / usr/src/redhat/RPMS/ `arch` / package.rpm installs a built package from a rpm source code
Rpmbuild-- rebuild package_name.src.rpm builds a rpm package from a rpm source code
12. YUM package upgrader-(Fedora, RedHat and similar systems)
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 solve all dependencies for you
Yum package_name.rpm updates all installed rpm packages on the current system
Yum package_name updates a rpm package
Yum remove package_name deletes a rpm package
Yum list lists all packages installed on the current system
Yum search package_name searches rpm repository for software packages
Yum clean packages cleans the rpm cache and deletes downloaded packages
Yum clean headers deletes all header files
Yum clean all deletes all cached packages and header files
13. DEB package (Debian, Ubuntu and similar systems)
Dpkg-I package.deb install / update a deb package
Dpkg-r package_name removes a deb package from the system
Dpkg-l displays all installed deb packages in the system
Dpkg-l | grep httpd displays all deb packages with the word "httpd" in their names
Dpkg-s package_name gets information about a special package that has been installed in the system
Dpkg-L package_name displays a list of files provided by a deb package that has been installed in the system
Dpkg-contents package.deb displays a list of files provided by a package that has not yet been installed
Dpkg-S / bin/ping confirms which deb package provides the given file
14. APT software tools (Debian, Ubuntu and similar systems)
Apt-get install package_name install / update a deb package
Apt-cdrom install package_name installs / updates a deb package from CD
Software packages in the apt-get upgrade list
Apt-get upgrade upgrades all installed software
Apt-get remove package_name removes a deb package from the system
Apt-get check confirms that the dependent software repository is correct
Apt-get clean cleans the cache from the downloaded package
Apt-cache search searched-package returns the name of the package containing the string you want to search for
15. View the contents of the file
Cat file1 looks forward at the contents of the file from the first byte
Tac file1 starts from the last line to view the contents of a file in reverse
More file1 looks at the contents of a long file
Less file1 is similar to the 'more' command, but it allows the same reverse operation in the file as the forward operation
Head-2 file1 looks at the first two lines of a file
Tail-2 file1 looks at the last two lines of a file
Tail-f / var/log/messages view what has been added to a file in real time
16. Text processing
Cat file1 file2... | command file1_in.txt_or_file1_out.txt general syntax for text manipulation using PIPE, STDIN and STDOUT
Cat file1 | command (sed, grep, awk, grep, etc...) > result.txt merges the detailed description text of a file and writes the introduction to a new file
Cat file1 | command (sed, grep, awk, grep, etc...) > > result.txt merges the detailed description text of a file and writes the introduction to an existing file
Grep Aug / var/log/messages look for the keyword "Aug" in the file'/ var/log/messages'
Grep ^ Aug / var/log/messages look for words starting with "Aug" in the file'/ var/log/messages'
Grep [0-9] / var/log/messages Select all lines that contain numbers in the'/ var/log/messages' file
Grep Aug-R / var/log/* searches for the string "Aug" in the directory'/ var/log' and subsequent directories
Sed's example.txt example.txt 1 / 2 example.txt replace "string1" with "string2" in the example.txt file.
Sed'/ ^ $/ d'example.txt removes all blank lines from the example.txt file
Sed'/ * # / d; / ^ $/ d 'example.txt removes all comments and blank lines from the example.txt file
Echo 'esempio' | tr' [: lower:]'[: upper:] 'merge the contents of the upper and lower cells
Sed-e '1d' result.txt excludes the first line from the file example.txt
Sed-n'/ stringa1/p' view lines that contain only the word "string1"
Sed-e's / * $/ / 'example.txt removes the white space character at the end of each line
Sed-e's example.txt Stringa1 example.txt removes only the word "string1" from the document and retains the rest
Sed-n'1 example.txt 5pbot 5q' view the content from line 1 to line 5
Sed-n'5p * 5q' example.txt view line 5
Sed-e's example.txt replace multiple zeros with a single zero
The number of lines in the cat-n file1 marking file
Cat example.txt | awk 'NR%2==1' deletes all even lines in the example.txt file
Echo a b c | awk'{print $1} 'view the first column of a row
Echo a b c | awk'{print $1 and 3} 'view the first and third columns of a row
Paste file1 file2 merges the contents of two files or columns
Paste-d'+ 'file1 file2 merges the contents of two files or columns, distinguished by "+" in the middle
Sort file1 file2 sorts the contents of two files
Sort file1 file2 | uniq fetches the union of two files (only one copy of duplicate lines is retained)
Sort file1 file2 | uniq-u delete the intersection and leave other lines
Sort file1 file2 | uniq-d takes out the intersection of two files (leaving only files that exist in both files)
Comm-1 file1 file2 compares the contents of two files and deletes only the contents contained in 'file1'
Comm-2 file1 file2 compares the contents of the two files and deletes only the contents contained in 'file2'
Comm-3 file1 file2 compares the contents of two files and deletes only the common parts of the two files
17. Character setting and file format conversion
Dos2unix filedos.txt fileunix.txt converts the format of a text file from MSDOS to UNIX
Unix2dos fileunix.txt filedos.txt converts the format of a text file from UNIX to MSDOS
Recode.. HTML
< page.txt >Page.html converts a text file to html
Recode-l | more displays all allowed conversion formats
18. File system analysis
Badblocks-v / dev/hda1 checks for bad blocks on disk hda1
Fsck / dev/hda1 repair / check the integrity of the linux file system on hda1 disk
Fsck.ext2 / dev/hda1 repair / check the integrity of the ext2 file system on hda1 disk
E2fsck / dev/hda1 repair / check the integrity of the ext2 file system on hda1 disk
E2fsck-j / dev/hda1 repair / check the integrity of the ext3 file system on hda1 disk
Fsck.ext3 / dev/hda1 repair / check the integrity of the ext3 file system on hda1 disk
Fsck.vfat / dev/hda1 repair / check the integrity of the fat file system on hda1 disk
Fsck.msdos / dev/hda1 repair / check the integrity of the dos file system on hda1 disk
Dosfsck / dev/hda1 repair / check the integrity of the dos file system on hda1 disk
19. Initialize a file system
Mkfs / dev/hda1 creates a file system in the hda1 partition
Mke2fs / dev/hda1 creates a linux ext2 file system in the hda1 partition
Mke2fs-j / dev/hda1 creates a linux ext3 (journal) file system in the hda1 partition
Mkfs-t vfat 32-F / dev/hda1 create a FAT32 file system
Fdformat-n / dev/fd0 format a floppy disk
Mkswap / dev/hda3 creates a swap file system
20. SWAP file system
Mkswap / dev/hda3 creates a swap file system
Swapon / dev/hda3 enables a new swap file system
Swapon / dev/hda2 / dev/hdb3 enables two swap partitions
21. Backup
Dump-0aj-f / tmp/home0.bak / home make a full backup of the'/ home' directory
Dump-1aj-f / tmp/home0.bak / home make an interactive backup of the'/ home' directory
Restore-if / tmp/home0.bak restore an interactive backup
Rsync-rogpav-/ home / tmp synchronizes directories on both sides
Rsync-rogpav-e ssh-/ home ip_address:/tmp through SSH channel rsync
Rsync-az-e ssh-- ip_addr:/home/public / home/local synchronizes a remote directory to a local directory through ssh and compression
Rsync-az-e ssh-/ home/local ip_addr:/home/public synchronizes the local directory to the remote directory through ssh and compression
Dd bs=1M if=/dev/hda | gzip | ssh user@ip_addr'dd of=hda.gz' performs a backup of the local disk on the remote host through ssh
Dd if=/dev/sda of=/tmp/file1 backs up the disk contents to a file
Tar-Puf backup.tar / home/user performs an interactive backup operation to the'/ home/user' directory
(cd / tmp/local/ & & tar c. ) | ssh-C user@ip_addr'cd / home/share/ & & tar x-p 'copy the contents of a directory in a remote directory through ssh
(tar c / home) | ssh-C user@ip_addr'cd / home/backup-home & & tar x-p 'copy a local directory in the remote directory through ssh
Tar cf -. | | (cd / tmp/backup; tar xf -) locally copy a directory to another place, retaining the original permissions and links |
Find / home/user1-name'* .txt'| xargs cp-av-- target-directory=/home/backup/-- parents finds and copies all files ending in '.txt' from one directory to another directory
Find / var/log-name'* .log'| tar cv-- files-from=- | bzip2 > log.tar.bz2 finds all files ending in '.log' and makes them into a bzip package
Dd if=/dev/hda of=/dev/fd0 bs=512 count=1 makes an action to copy the MBR (Master Boot Record) content to the floppy disk.
Dd if=/dev/fd0 of=/dev/hda bs=512 count=1 restores MBR content from a backup that has been saved to a floppy disk
22. CD
Cdrecord-v gracetime=2 dev=/dev/cdrom-eject blank=fast-force clear the contents of a rewritable disc
Mkisofs / dev/cdrom > cd.iso creates an iso image of the CD on disk
Mkisofs / dev/cdrom | gzip > cd_iso.gz creates a compressed CD-iso image file on disk
Mkisofs-J-allow-leading-dots-R-V "Label CD"-iso-level 4-o. / cd.iso data_cd create a directory iso image file
Cdrecord-v dev=/dev/cdrom cd.iso burns an ISO image file
Gzip-dc cd_iso.gz | cdrecord dev=/dev/cdrom-Burns a compressed ISO image file
Mount-o loop cd.iso / mnt/iso mounts an ISO image file
Cd-paranoia-B transcribes audio tracks from a CD CD to a wav file.
Cd-paranoia-- "- 3" transcribed audio tracks from a CD CD to wav files (parameter-3)
Cdrecord-scanbus scan bus to identify scsi channels
Dd if=/dev/hdc | md5sum verifies the md5sum code of a device, such as a CD
Thank you for reading! This is the end of this article on "what are the common commands in Linux?". I hope the above content can be of some help to you, so that you can learn more knowledge. if you think the article is good, you can share it for more people to see!
Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.
Views: 0
*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
"Every 5-10 years, there's a rare product, a really special, very unusual product that's the most un
© 2024 shulou.com SLNews company. All rights reserved.