* * * *

* * * *

System information


Arch displays the processor architecture of the machine (1) uname -m displays the processor architecture of the machine (2) uname -r displays the kernel version in use dMIDecode -q displays the hardware system components - (SMBIOS/DMI) hdparm -i /dev/hda List the architecture features of a disk hdparm-tt /dev/sda Perform test reads on the disk cat /proc/cpuInfo Displays CPU info information cat /proc/Interrupts Displays interrupt cat Cat /proc/meminfo Uses cat /proc/swaps to check which swaps are used. Cat /proc/version Displays the kernel version. Cat /proc/net/dev displays network adapters and mounts statistics Lsusb-tv display USB device date Display system date CAL 2007 Display 2007 calendar date 041217002007.00 Set date and time - The month and day are divided into years. Second clock -w Saves the time change to the BIOSCopy the code

* * * *

Shutdown (shutdown, restart, and logout of the system)\


Shutdown -h now shutdown the system (1) init 0 shutdown the system (2) telinit 0 shutdown the system (3) shutdown -h hours:minutes & shutdown the system at the scheduled time shutdown -c cancel the shutdown at the scheduled time Shutdown -r Now Restart (1) reboot Restart (2) LogoutCopy the code

* * * *

* * * *

Disabling the Firewall


1.2 Disabling the Firewall Run the following command: service iptables stop Verify: service iptables status 1.3 Disabling the automatic running of the firewall Run the following command: chkconfig iptables off Verify: chkconfig --list | grep iptablesCopy the code

* * * *

\ yum upgrade/yum update

Yum update updates all packages and the system kernelCopy the code

* * * *

Yum -y install vim nmap GCC Telnet wget zip unzip openssh-clients\


GCC: yum -y install GCC: yum -y install Telnet: yum -y install wget: yum -y install wget: yum -y install wget: yum -y install wget: yum -y install wget: yum -y install wgetCopy the code

* * * *

Linux configuration IP address :\


Vim /etc/sysconfig/network-scripts/ifcfg-eth0 DEVICE=eth0 TYPE=Ethernet ONBOOT=yes BOOTPROTO=static IPADDR=192.168.1.110 NETMASK=255.255.255.0 PREFIX=24 GATEWAY=192.168.1.1 DNS1=192.168.1.1 DEFROUTE=yes IPV4_FAILURE_FATAL=yes IPV6INIT=no NAME="eth0" ARPCHECK=no Start editing, and fill in the IP address, subnet mask, gateway, and DNS.Copy the code

* * * *

\

Run the following command to restart nic 2: vi /etc/sysconfig/network-scripts/ifcfg-eth0 /etc/sysconfig/network-scripts/ifcfg-eth0 /etc/sysconfig/network-scripts/ifcfg-eth0 /etc/udev/rules.d/70-persistent-net.rules /etc/udev/rules.d/70-persistent-net.rules /etc/udev/rules.d/70-persistent-net.rules /etc/udev/rules.d/70-persistent-net. You can also edit the configuration file directly to change the network card and MAC address multiplied by the corresponding, but so much trouble, directly delete restart, it will automatically generate a. Run the following command to query a route: route -n Run the following command to delete a route: route del-net 169.254.0.0 netmask 255.255.0.0 eth0Copy the code

* * * *

* * * *

Files and directories \


CD /home Go to '/ home' directory 'CD.. Return to the upper directory CD.. /.. CD to go to the personal home directory CD ~user1 To go to the personal home directory CD - To go to the last directory PWD Display the working path ls View files in the directory ls -f View files in the directory ls -l Display details about files and directories ls -a Display hidden files ls *[0-9]* Display file names and directory names containing numbers tree Display tree structure of files and directories starting from root (1) lstree Display tree structure of files and directories starting from root (2) mkdir dir1 Create a directory called 'dir1' Mkdir dir1 dir2 Create both directories mkdir -p/TMP /dir1/dir2 Create a directory tree rm -f file1 Delete a file called 'file1' 'rmdir dir1 Delete a directory called 'dir1'' Rm -rf dir1 Delete a directory named 'dir1' and delete its contents rm -rf dir1 dir2 Delete two directories and their contents mv dir1 new_dir Rename/move a directory cp file1 file2 Copy 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 Create a soft link to a file or directory ln file1 lnk1 Create a physical link to a file or directory touch -t 0712250000 Outputs iconv -l to modify the time stamp of a file or directory - (YYMMDDhhmm) file file1 the MIME type of the file as text iconv -l lists the known encoditiesCopy the code

* * * *

File search \


Find / -name file1 Searches for files and directories in the root file system starting from '/'. Find / -user user1 Searches for files and directories belonging to user 'user1'. Find /home/user1-name \* Find /usr/bin-type f-atime +100 Search for the execution file that has not been used in the past 100 days find /usr/bin-type f-mtime-10 Find / -name \*. RPM -exec chmod 755 '{}' \; Find / -xdev-name \*. RPM Find / -xdev-name \*. RPM Find / -xdev-name \*. RPM Ignore the CD drive, flash drive, etc. Locate \*.ps to find a file ending in '. Ps' - first run the 'updatedb' command whereis halt to display a binary file, source code, or the location of man which halt Displays the full path to a binary or executable fileCopy the code

* * * *

Mount a file system \


Mount /dev/hda2 / MNT /hda2 Mount a disk named hda2 - Make sure the directory '/ MNT /hda2' already exists umount /dev/hda2 Unmount a disk named hda2 - exit from the mount point '/ MNT /hda2' first Fuser -km/MNT /hda2 Forcibly unmount the device when it is busy umount -n/MNT /hda2 Run the unmount operation without writing the /etc/mtab file - Useful when the file is read-only or 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 Mount a file or ISO image file mount -t vfat /dev/hda5 / MNT /hda5 Mount a Windows FAT32 file system mount /dev/sda1 / MNT /usbdisk Mount a USB flash drive or flash memory device mount -t SMBFS -o username=user,password=pass //WinClient/share/MNT /share mounts a Windows network shareCopy the code

* * * *

Disk space \


Df -h display the list of partition is mounted ls - lSr | more arranged in size file and directory du - sh dir1-name estimate directory 'dir1-name' have to use the disk space 'du - sk * | sort - rn) based on size, in turn, according to the size of the files and directories RPM - q - a - qf '10 {NAME} {SIZE} t % % n' | sort - k1, 1 n based on the SIZE of the display has been installed in turn the space used by RPM package (fedora, Dpkg-query-w-f ='${installed-size; 10} ${Package} n 't | sort - k1, 1 n based on the size of the display installed deb Package used by space (ubuntu, debian system)Copy the code

* * * *

Users and groups \


Groupadd group_name Creates a user group groupdel group_name Deletes a user group groupmod -n new_group_name old_group_name Renames a user group useradd -c "Name Surname "-g admin -d /home/user1 -s /bin/bash user1 Create a user belonging to user group admin useradd user1 Create a new user userdel -r user1 Delete a User ('-r' excludes the home directory) usermod -c "User FTP" -g system -d/FTP /user1 -s /bin/nologin user1 Modify the User attribute passwd Modify the password passwd user1 Change the password of a user (root only) chage -e 2005-12-31 user1 Set the validity period of the user password PWCK Check the file format and syntax of '/etc/passwd' and the existence of user GRPCK check File format and syntax fixes for '/etc/passwd' and existing group newgrp group_name logs into a new group to change the default group for newly created filesCopy the code

* * * *

File permissions \


File permissions - Use "+" to set permissions, The use of "-" is used to cancel the ls - lh show permissions ls/TMP | pr - T5 - W $COLUMNS will be divided into terminal 5 bar shows chmod ugo + RWX directory1 set directory of all the people (u), group (g) and others (o) to read (r ), write (w), and execute (x) permissions chmod go-rwx directory1 Deletes the read and write execute permissions on directories of groups (G) and others (O) chown user1 file1 Changes the owner attribute of a file chown -r user1 Directory1 Changes the owner properties of a directory and all files in the directory CHGRP group1 file1 Group in which the file is changed chown user1:group1 file1 Changes the owner and group properties of a file find / -perm -u+s Lists all files in a system that use SUID control chmod u+s /bin/file1 Sets the SUID bit of a binary file - The user running the file is also granted the same permissions as the owner chmod u-s /bin/file1 Chmod g+s /home/public Sets the SGID bit of a directory - similar to SUID, Chmod g-s /home/public Disables the SGID bit of a directory chmod o+t /home/public sets the STIKY bit of a file - only allows legal owners to delete files chmod o-t /home/public Disables the STIKY bit of a directoryCopy the code

* * * *

\

File special properties - use "+" to set permissions, Chattr +c file1 allows the file to be automatically compressed/uncompressed by the kernel. Chattr +d file1 allows the file to be automatically compressed/uncompressed by the kernel. Chattr +s file1 allows a file to be safely deleted once an application writes to the file. Chattr +s file1 Chattr +u file1 If a file is deleted, the system will allow you to restore the deleted file later. Lsattr displays special propertiesCopy the code

* * * *

Package and compress files \


Bz2 unzip a file called 'file1.bz2' bzip2 file1 unzip a file called 'file1. gunzip file1.gz Unzip a file called 'file1.gz' gzip file1 Compress a file called 'file1' gzp-9 file1 compress rar a file1.rar test_file Create a package called 'file1.rar' Also compress 'file1', 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 a file containing 'file1', Tar displays the contents of a package. Tar -xvf archive.tar Releases a package. Tar -xvf archive.tar -c/TMP releases the compressed package to Bz2 dir1 Create a package in bzip2 format: tar -xvfj archive.tar.bz2 Decompress a package in bzip2 format: tar -cvfz Gz dir1 Create a compressed package in gzip format. Tar -xvfz archive.tar.gz Decompress a compressed package in gzip format. Zip file1.zip create a compressed package in ZIP format Zip file1 file2 dir1 Compress several files and directories into a ZIP package. Unzip file1.zip Decompresses a ZIP packageCopy the code

* * * *

\

RPM package - (Fedora, RPM For Redhat or similar systems) RPM -ivh package. RPM Install 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. The RPM update a sure you have installed the RPM package RPM -e package_name. RPM to remove an RPM package RPM - qa list all installed in the system of RPM package RPM - qa | RPM -qi package_name To obtain special information about an installed package RPM -qg "System Environment/Daemons" RPM -ql package_name Indicates the installed RPM package. RPM -qc package_name Indicates the installed RPM package. RPM -q package_name Indicates the installed RPM package --whatrequires Displays the list of dependencies with an RPM package RPM -q package_name -- WHATprovides Displays the volume occupied by an RPM package RPM -q package_name --scripts Display during the install/remove script execution by l package_name RPM - q - changelog show a RPM package revision history RPM - qf/etc/HTTPD/conf/HTTPD. Conf the confirmation to the documents provided by which RPM package RPM -qp package. RPM -l Displays the list of files provided by an uninstalled RPM package RPM --import /media/cdrom/RPM -gpg-key Imports the public KEY digital certificate RPM --checksig package. RPM Check the integrity of an RPM package RPM -qa gpg-pubkey Check the integrity of all RPM packages RPM -v package_name Check the file size, license, type, owner, group, MD5 check, and last modified time RPM -va Check all installed in the system of RPM package - be careful to use the RPM - Vp package. The RPM confirmed an RPM package is not installed rpm2cpio package. The RPM | cpio, extract, the make - bin directories * * Run the executable from an RPM package RPM -ivh /usr/src/redhat/rpms/' arch '/package. RPM Install a built package rpmbuild --rebuild from an RPM source Package_name.src. RPM Builds an RPM package from an RPM sourceCopy the code

* * * *

* * * *

**YUM Package upgrader – (Fedora, RedHat and similar systems) **

Install package_name yum localinstall package_name. RPM Yum update package_name yum update package_name yum update package_name yum remove Package_name Yum list Yum search package_name Yum search package_name Yum clean packages Yum clean packages Yum Clean All Deletes all cached packages and headersCopy the code

\

**DEB packages (Debian, Ubuntu, and similar systems) **

DPKG -i package. Deb installation/update a deb package DPKG -r package_name deleted from the system a deb package DPKG -- l display system all has been installed in the deb package DPKG -l | grep HTTPD DPKG -l package_name Specifies the name of a deb package that has been installed in your system --contents package.deb displays the list of files provided by a package that has not yet been installed. DKG -s /bin/ping confirms which deb is providing the given fileCopy the code

* * * *

APT software tools (Debian, Ubuntu and similar systems)\


Apt-get install package_name Install deb package apt-cdrom install package_name Install deb package apt-cdrom install package_name Install deb package apt-get update install deb package Apt-get upgrade Upgrade all installed software apt-get remove package_name delete a deb package from the system apt-get check Check dependent repositories correct apt-get clean Clean the cache from downloaded software packages Apt-cache search searched-package returns the name of the package containing the searched stringCopy the code

* * * *

View file contents \


Cat file1 Displays the contents of a file from the first byte forward. Tac file1 Displays the contents of a file from the last line in reverse. More file1 Displays the contents of a long file. But it allows you to perform the same reverse operation in a file as in the forward operation head-2 file1 View the first two lines of a file tail -2 file1 View the last two lines of a file tail -f /var/log/messages View the contents of a file in real timeCopy the code

* * * *

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 merge a text file detailed instructions, and during the introduction to writing a new file cat file1 | command (sed, grep, awk, grep, etc...). >> result.txt To merge a file's verbose text, Grep Aug /var/log/messages Find the keyword "Aug" in the file '/var/log/messages' grep ^Aug /var/log/messages in the file Grep [0-9] /var/log/messages Select all lines containing numbers in the '/var/log/messages' file grep Aug -r /var/log/* Search for the string "Aug" sed 's/stringa1/stringa2/g' example.txt replace "string1" in example.txt with "string2" sed '/^$/d' example.txt delete all blank lines from example.txt sed '/ *#/d; / ^ $/ d 'example. TXT from example. TXT file delete all comments and blank lines echo' esempio '| tr / : the lower: "' [: upper:] 'merger sed up and down the cell contents - e 1 d' Sed -e 's/ *$//' example. TXT removes the blank character sed at the end of each line from the file example. TXT -e 's/stringa1//g' example. TXT delete only the word "string1" from the file and keep the rest of it. Sed -n '5p; sed -n '5p; sed -n '5p; 5 q 'example. TXT see line 5 sed -e' 00 s / * / 0 / g 'example. TXT replace multiple with a single zero zero cat cat - n file1 labeled file lines example. TXT | awk' NR % 2 = = 1 ' Delete example. TXT file all even lines of the echo a b c | awk '{print $1}' view the line of the first column echo a b c | awk '{print $1, $3}' to view a line of the first and the third column paste file1 Paste -d '+' file1 File2 combines the contents of two files or columns. "+" to distinguish between sort file1 file2 sort the contents of two files sort file1 file2 | uniq took out two files and set (duplicate rows only keep a) sort file1 file2 | uniq - u delete the intersection, Leave other line sort file1 file2 | uniq - d out the intersection of two files, leaving only exists in two files at the same time files) in a comm - 1 file1 file2 compares the contents of two files to delete "file1" only contain the contents of the comm - 2 File1 file2 Compares the contents of 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 filesCopy the code

* * * *

Character Settings and file format conversion \


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. The HTML to convert a text file to HTML recode - l | more show all allow conversion formatsCopy the code

File system analysis \


Badblocks -v /dev/hda1 Check bad magnetic blocks on disk hda1 FSCK /dev/hda1 Repair/Check the integrity of the Linux file system on disk hda1 fsck.ext2 /dev/hda1 Restore the integrity of the ext2 file system on hda1 e2fsck /dev/hda1 Restore the integrity of the ext2 file system on hda1 e2fsck -j /dev/hda1 Restore the integrity of the ext3 file system on hda1 Ext3 /dev/hda1 Repair/Check the integrity of the ext3 file system on hda1 fsck.vfat /dev/hda1 Repair/Check the integrity of the FAT file system on hda1 fsck.msdos /dev/hda1 Dosfsck /dev/hda1 Repair/check the integrity of the DOS file system on the Hda1 diskCopy the code

* * * *

* * * *

Example Initialize a file system


MKFS /dev/hda1 Create a file system in hda1 partition mke2fs /dev/hda1 Create a Linux ext2 file system in hda1 partition mke2fs -j /dev/hda1 Create a Linux in hda1 partition MKFS -t vfat 32 -f /dev/hda1 Creates a FAT32 file system fdformat -n /dev/fd0 formats a floppy disk mkswap /dev/hda3 Creates a swap file systemCopy the code

* * * *

SWAP file system \

Mkswap /dev/hda3 Create a swap file system swapon /dev/hda3 Enable a new swap file system swapon /dev/hda2 /dev/hdb3 Enable two swap partitionsCopy the code

* * * *

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 --delete /home/tmp Synchronize directories on both sides rsync-rogpav -e SSH --delete /home Ip_address :/ TMP Through the SSH channel rsync rsync-az -e SSH --delete ip_addr:/home/public /home/local Synchronize a remote directory to the local directory rsync-az through SSH and compression - e SSH -- delete/home/local ip_addr: / home/public via SSH and compression to local directory synchronization to the remote directory dd bs = 1 m if = / dev/hda | gzip | SSH user @ ip_addr 'dd of=hda.gz' Backs up the local disk on the remote host using SSH dd if=/dev/sda of=/ TMP /file1 Backs up the disk content to a file tar -puf backup.tar /home/user Performs a pair of files Directory '/ home/user interactive backup operation (CD/TMP/local / && tar c.) | SSH - c user @ ip_addr' CD/home/share / && tar x - p ' Via SSH to copy a directory content in the remote directory (tar c/home) | SSH - c user @ ip_addr 'CD/home/backup - home && tar x - p' via SSH in the remote directory replication tar cf a local directory - . | (cd /tmp/backup ; Tar xf -) locally copy a directory to another location, Retain the original permissions and link the find/home/user1 - the name '*.txt' | xargs cp - av -- target - directory = / home/backup / -- parents from a directory to find and copy all to '. TXT ' At the end of the file to another directory, find the/var/log - the name '*. The log' | tar CV - files - from = - | bzip2 > the tar. The.bz2 find all to 'log' at the end of the file and make a bzip package dd If =/dev/hda of=/dev/fd0 bs=512 count=1 Copy the MBR (Master Boot Record) to the floppy disk dd if=/dev/fd0 of=/dev/hda bs=512 count=1 Restores MBR content from a backup already saved to floppy diskCopy the code

* * * *

CD \


Cdrecord -v gracetime=2 dev=/dev/cdrom -eject blank= fast-force Clears the contents of a copyable CD mkisofs /dev/cdrom > cd.iso On disk to create a CD iso image file mkisofs/dev/cdrom | gzip > cd_iso. Gz on disk to create a compressed the cd-rom iso image files mkisofs -j - allow - leading - dots - R - V "Label CD" -iso-level 4 -o./cd.iso data_cd Create an ISO image file for a directory cdRecord -v dev=/dev/cdrom cd.iso Create an ISO image file gzip -dc Cd_iso. Gz | cdrecord dev = / dev/cdrom - burn a compressed the ISO image file mount -o loop CD. ISO/MNT/ISO mount an ISO image file CD, paranoia, and B Transcription from a CD tracks to wav files in CD - paranoia, "3" from a CD transcription track to wav file (parameters - 3) cdrecord - scanbus scan bus in order to identify the SCSI channel dd if = / dev/HDC | Md5sum Verifies the MD5SUM encoding of a device, such as a CDCopy the code

* * * *

Networking – (Ethernet and WIFI wireless) \


Ifconfig eth0 Displays the configuration of an Ethernet card. Ifup eth0 Enables one 'eth0' network device. Ifdown eth0 Disables one 'eth0' network device 255.255.255.0 Control IP address ifconfig eth0 promisc Set 'eth0' to promiscuous mode to sniff packets dhclient eth0 Enable 'eth0' in DHCP mode.Copy the code


\

* * * *