Linux common commands Daquan (very full !!!)
And recently in dealing with Linux, I feel pretty good. I think Linux windows more troublesome is that many things will be compared with commands to control, of course, this is also the reason a lot of people like linux, is small but powerful. I will list what I learned command, only for your reference:
The system information
arch show architecture of machine
uname -m show architecture of machine
uname -r kernel version is displayed using
dmidecode -q display hardware system components - (the SMBIOS / the DMI)
hdparm -i / dev / HDA disk listed the architectural features
hdparm -tT / dev / sda perform test on the disk read operations of
cat / proc / cpuinfo show information CPU info
cat / proc / interrupts show interrupts
cat / proc / meminfo verify memory use
cat / proc / swaps shows which are used swap
cat / proc / version show version of the kernel
cat / proc / net / dev show network adapter and statistics
cat / proc / mounts show mounted file system
lspci -tv listed PCI devices
lsusb -tv show USB device
date the display system date
cal 2007 show the 2007 calendar
date 041217002007.00 set the date and time - division in second day of
clock -w will save time to modify the BIOS
shutdown (system shutdown, restart, and log out)
the shutdown -h now closed systems
Shut down the system init 0
telinit 0 shut down the system
shutdown -h hours: minutes & close as scheduled system
shutdown -c cancel the shutdown of the system time
shutdown -r now reboot
reboot reboot
logout Logs
files and directories
cd / home enter '/ home' directory '
cd .. go back one level
cd ../ .. return to the two directory
cd go to home directory
cd ~ user1 go to home directory
cd - returns the last directory where
pwd show the path of work
ls to view directories file
ls -F view files in a directory
ls -l show details of files and directories
ls -a show hidden files
ls * [0-9] * display contains a number of file and directory names
tree display files and directories from the root directory tree begins
lstree display files and directories starting from the root of the tree
mkdir dir1 create a 'dir1' directory is called '
mkdir dir1 dir2 create two directories simultaneously
mkdir -p / tmp / dir1 / dir2 create a directory tree
rm -f file1 delete called 'file1' file '
rmdir dir1 delete called 'dir1' directory '
dir1' delete directory called rm -rf dir1 'and deletes its contents
rm -rf dir1 dir2 simultaneously remove two directories and their contents
mv dir1 new_dir rename / move a directory
cp file1 file2 copying a file
cp dir / *. copy all files in a directory to the current working directory
cp -a / tmp / dir1. copy a directory within the current work directory
cp -a dir1 dir2 copy a directory
cp -r dir1 dir2 copy a directory and subdirectories
ln -s file1 lnk1 create a link to the file or directory soft link
ln lnk1 create a link to the file or directory physical link file1
Touch -t 0.71225 billion file1 modify timestamp of a file or directory - (YYMMDDhhmm)
File file1 Outputs the File the MIME type of text AS
iconv -l lists known encoding
iconv -f fromEncoding -t toEncoding inputFile> outputFile creates a new from the given input file by assuming it is encoded in fromEncoding and . Converting to toEncoding IT
. Find. 1 -maxdepth -name * .jpg -print -exec Convert "{}" -resize 80x60 "thumbs / {}" \; BATCH a resize Files in Current Directory The Them to Send and Thumbnails A Directory ( requires convert from Imagemagick)
file search
find / -name file1 from the '/' entered the root file system searches files and directories
find / -user user1 search belongs to the user 'user1' files and directories
find / home / user1 -name \ * . bin in the directory '/ home / user1' searches with '.bin' end of the file
find / usr / bin -type f -atime +100 search has not been used in the past 100 days binary files are
find / usr / bin -type f -mtime -10 search created or modified file within 10 days
find / -name \ * rpm -exec chmod 755 '{}' \;. in search '.rpm 'the end of the file and define its authority
find / -xdev -name \ *. rpm Search to' .rpm 'end of the file, ignoring the CD-ROM drive, pen-drive and other removable devices
locate \ *. ps looking to' ending .ps' of file - first run 'updatedb' command
whereis halt the display position of a binary file, a source or man
which halt show full path of a binary executable file or
mount a file system
mount / dev / hda2 / mnt / hda2 mount a the disc is called hda2 - determining the directory '/ mnt / hda2' already exists
umount / dev / hda2 discharge tray called hda2 - start mount point '/ mnt / hda2' Exit
fuser -km / mnt / hda2 forced to unload when the device is busy
umount -n / mnt / hda2 run umount without writing / etc / mtab file - or when the file is read-only is useful when the disk is full
mount / dev / fd0 / mnt / floppy diskette mount a
mount / dev / cdrom / mnt / cdrom mount a cdrom or dvdrom
Mount / dev / HDC / mnt / cdrecorder or mount a cdrw dvdrom
Mount / dev / HDB / mnt / cdrecorder or mount a cdrw dvdrom
Mount -o Loop file.iso / mnt / CDROM mount an ISO image file or
mount -t vfat / dev / hda5 / mnt / hda5 mount a Windows FAT32 file system
mount / dev / sda1 / mnt / usbdisk mount a disk or flash usb pen
mount -t smbfs -o username = user, password = pass // WinClient / share / mnt / share mount a windows network shared
disk space
df -h display has hung uploaded partition list
ls -lSr | more aligned to the size of the files and directories
du -sh dir1 estimate disk space directory 'dir1' already used '
du -sk * | -rn to the Sort size based on capacity in order to display files and directories size
rpm -q -a --qf '% 10 { sIZE} t% {NAME} n' | sort -k1,1n sequentially displayed by size space (fedora, redhat based system) installed rpm packages used
dpkg-query -W -f = '$ {Installed-Size; 10} t $ {Package} n' | sort -k1,1n display space by size (ubuntu, debian-based system has been installed deb packages used )
users and groups
groupadd group_name create a new user group
groupdel group_name delete 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 create a user belongs "admin" user group
useradd user1 create a new user
userdel -r user1 delete a user ( '-r' eliminates home directory)
the usermod -c "the user the FTP" -g System -d / the FTP / user1 - s / bin / nologin user1 modify user attributes
passwd Change password
passwd user1 change a user password (only perform root)
the chage -E 2005-12-31 user1 set password expiration period
pwck check '/ etc / passwd' file correct syntax and format and the user's presence
grpck check '/ etc / passwd' correct syntax and format file group and present
newgrp group_name log into a new group to change default group of newly created files
file permissions - using the "+" to set permissions, use the "-" is used to cancel
ls -lh permission to display the
ls / tmp | pr -T5 - W $ cOLUMNS 5 bar into the terminal display
chmod ugo + rwx directory1 all set directory (u), the group (g) and others (o) to read (r), write (w) and execute (x) permissions
chmod go-rwx directory1 delete a group (g) and others (o) implementation of read and write access to a directory
user1 file1 change owner of a file's properties chown
chown -R user1 directory1 change all of the properties of a directory and at the same time changing the properties of all files under the directory to change
the group chgrp group1 file1 file changes
chown user1: group1 file1 changes and group ownership of a file
find / -perm -u + s list of all uses a file system control SUID
chmod u + s / bin / file1 provided a SUID bit binary file - the user running the file and are each assigned to the same owner permissions
chmod us / bin / file1 disable SUID bit on a binary file
chmod g + s / home / set a public purpose The SGID bit - similar to SUID, but this is for directory
chmod gs / home / public disable SGID bit on a directory
chmod o + t / home / public set STIKY bit of a file - delete files allow only legitimate owners
chmod ot / home / public disable STIKY bit of a directory
file of special attributes - use the "+" to set permissions and "-" for canceling
chattr + a file1 append mode allows only read or write files
chattr + c file1 file by the kernel allows this compression / decompression automatically
chattr + d file1 when performing file system backup, dump program ignores file
chattr + i file1 an immutable file can not be deleted, modify, rename, or linked
chattr + s file1 allows a file to be safely deleted
S file1 the result immediately modified chattr + Once the application has been written to this file, the system written to disk
chattr + u file1 If the file is deleted, the system will allow you to recover the contents of a file is deleted
lsattr show special attributes
packaged and compressed files
bunzip2 file1.bz2 decompression called 'file1.bz2' files
bzip2 file1 compression called 'file1' files
gunzip file1.gz decompression called 'file1.gz' file
gzip file1 compress called ' file1 'file
gzip -9 file1 maximum degree of compression
rar a file1.rar test_file create called 'file1.rar' package
rar a file1.rar file1 file2 dir1 while compressing 'file1', 'file2', and directory 'dir1'
rar X file1.rar packet extracting rar
unrar x file1. rar extract the rar package
tar -cvf archive.tar file1 create a uncompressed tarball
tar -cvf archive.tar file1 file2 dir1 create a containing 'file1', 'file2' and 'dir1' archive
tar -tf archive.tar display the contents of a package
tar -xvf archive.tar release a package
tar -xvf archive.tar -C / tmp to release the compressed packet / tmp catalog
tar -cvfj archive.tar.bz2 dir1 create a compressed format bzip2
tar -jxvf archive.tar.bz2 extracting archive a bzip2 format of
tar -cvfz archive.tar.gz dir1 create a compressed gzip format of
tar -zxvf archive.tar.gz decompress a gzip format compressed
zip file1.zip file1 create a zip archive format
zip -r file1.zip file1 file2 dir1 several files and directories at the same time compressed into a compressed zip format
unzip file1.zip decompressing a compressed zip format
RPM package - (Fedora, Redhat and similar systems)
RPM -ivh Package. rpm install a rpm package
rpm -ivh --nodeeps package.rpm install a rpm package while ignoring dependencies
rpm -U package.rpm upgrade a rpm package without changing its profile
rpm -F package.rpm update has been installed to determine a the rpm package
rpm -e delete package_name.rpm a rpm package
rpm -qa show all rpm packages installed
rpm -qa | grep httpd show all the names included "httpd" word rpm package
rpm -qi package_name has acquired a specific information installation package
rpm -qg "System Environment / Daemons" show a package assembly rpm
rpm -ql package_name displays a list of files already installed rpm package provided
rpm -qc package_name profile displays an installed package provided rpm list
rpm -q package_name --whatrequires displays a list of dependencies rpm packet
rpm -q package_name --whatprovides display the volume occupied by a rpm package
rpm -q package_name --scripts displayed in the script l / deleted during the installation performed
rpm -q package_name --changelog show a modification history rpm package
rpm -qf /etc/httpd/conf/httpd.conf to confirm the documents which rpm package from the
rpm -qp package.rpm -l displays a list of files provided by a rpm package not yet installed
rpm --import / media / cdrom / RPM-GPG-KEY digital certificate of a public key
rpm --checksig package.rpm confirm the integrity of a rpm package
rpm -qa gpg-pubkey confirmed the integrity of all rpm packages installed
rpm -V package_name check file size, license, type, owner, group, MD5 checksum and last modification time
rpm -Va inspection systems all installed rpm package - used with care
rpm -Vp package.rpm confirm a rpm package not yet installed
rpm2cpio package.rpm | cpio - extract --make-directories * bin * run an executable file from a rpm package
rpm -ivh /usr/src/redhat/RPMS/`arch`/package.rpm from a rpm source mounting a package built
rpmbuild --rebuild package_name.src.rpm rpm construct a packet from a source rpm
YUM package upgrader - (Fedora, RedHat and similar systems)
yum the install package_name to download and install a rpm package
yum localinstall package_name.rpm mounting a package rpm use your own repositories for you to solve all dependencies
yum update package_name.rpm update the current system for all installed rpm package
yum update package_name upgrade a rpm package
yum remove package_name remove a rpm package
yum list list currently installed on your system All packages
yum search package_name search for packages in the warehouse rpm
yum clean packages to clean up rpm cache delete the downloaded package
yum clean headers remove all header files
yum clean all remove all cached packages and header files
DEB packages (Debian, Ubuntu and similar systems)
dpkg -i package.deb install / upgrade a deb package
dpkg -r package_name remove a deb package from the system
dpkg -l show all deb packages already installed system
dpkg -l | grep httpd show all the names contained the word "httpd" deb package
dpkg -s package_name obtain information on the system has been installed on a specific package
file dpkg -L package_name display system has been installed in a deb package provided by list
dpkg --contents package.deb display a list of files not yet installed a package offered by
dpkg -S / bin / ping to confirm the documents provided by the deb package which
APT software tool (Debian, Ubuntu and similar systems)
APT-GET install package_name install / upgrade a deb package
apt-cdrom install package_name install from a CD / upgrade a deb package
apt-get update update the list of package
apt-get upgrade upgrade all installed software
apt-get remove package_name remove a system from deb package
apt-get check to confirm the correct resolution of dependencies
apt-get clean clean up cache from packages downloaded
apt-cache search searched-package to return the package that contains the name to the search string
to view the contents of a file
cat file1 from the first byte positive view file contents
tac file1 view in reverse, starting from the last row of a Contents of the file
more file1 view the contents of a file along
less file1 similar to 'more' command, but it allows the operation of the forward and reverse operation in the same file,
the first two lines of a file head file1 view -2
tail -2 file1 view of a document the last two lines
tail -f / var / log / messages view in real time is added to the contents of a file in
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 description, and the introduction writes a new file
cat file1 | command (sed, grep , awk, grep, etc ...) >> result.txt a combined detailed description text file, and writes a profile existing file
grep Aug / var / log / messages in file '/ var / log / messages' in Find keyword "Aug"
grep-Aug ^ / var / log / messages in file '/ var / log / messages' to find "Aug" words beginning
grep [0-9] / var / log / messages select' / Var / log / messages' file numbers of all lines contained
grep Aug -R / var / log / * Search the directory '/ var / log' directory and subsequent string "-Aug"
Sed 'S / stringa1 / stringa2 / G' of example.txt in example.txt " string1 "replaced" string2 "
Sed '/ ^ $ / D' example.txt deleted from any blank row in example.txt
sed '/ * # / d; / ^ $ / d' example.txt file from example.txt remove all comments and blank lines
echo 'esempio' | tr '[ : lower:]' '[: upper:]' merge cell contents up and down
sed -e '1d' result.txt excluded from the first file example.txt row
row sed -n '/ stringa1 / p' view only contains the words "string1" the
sed -e 's / * $ // ' example.txt end of each row to delete blank character
sed -e 's / stringa1 // g 'example.txt removed from the document only the words "string1" and retain all remaining
sed -n' 1,5p; 5q 'example.txt view from the first to the fifth row of content
sed -n' 5p; 5q 'example .See txt line 5
's / 00 * / 0 / g' example.txt replaced with a single zero zero sed -e plurality of
rows cat -n file1 file designated
cat example.txt | all even rows awk 'NR% 2 == 1' delete example.txt file
echo abc | awk '{print $ 1}' view the first column of a line
echo abc | awk '{print $ 1, $ 3} 'view the first and third column line
paste file1 file2 merging two files or the contents of two columns
paste -d' + 'file1 file2 merging contents of two files or two columns, with the intermediate "+" to distinguish
sort file1 file2 sort contents of two files
sort file1 file2 | uniq of two files and set (only one copy of duplicate rows)
sort file1 file2 | uniq -u files by viewing only unique line
sort file1 file2 | uniq -d out two intersection of files (leaving only two files exist in the file)
content comm -1 file1 file2 compare two files to delete only content 'file1' contained
comm -2 file1 file2 compare two files is only It deleted included in the content 'file2'
COMM comparing two content -3 file1 file2 file delete only portions of both files
character sets and file format conversion
dos2unix filedos.txt fileunix.txt the format is converted from a text file into MSDOS UNIX
unix2dos fileunix.t xt filedos.
recode ..HTML <page.txt> page.html convert a text file into HTML
Recode -l | More show all allow conversion format
file system analysis
badblocks -v / dev / bad blocks on the magnetic disk check hda1 hda1
the fsck / integrity dev / hda1 repair / check disk hda1 linux file system
integrity fsck.ext2 / dev / hda1 repair / check disk hda1 ext2 file system
e2fsck / dev / hda1 complete the repair / inspection ext2 filesystem on disk hda1 sexual
integrity e2fsck -j / dev / hda1 repair / check disk hda1 ext3 file system
integrity fsck.ext3 / dev / hda1 repair / check disk hda1 ext3 file system
fsck.vfat / dev / hda1 repair / check hda1 the integrity of the file system on the disk fat
fsck.msdos / dev / hda1 repair / check on disk hda1 dos file system integrity
on dosfsck / dev / hda1 repair / check hda1 dos disk file system integrity
initialize a file system
mkfs / dev / hda1 create a filesystem on hda1 partition
mke2fs / dev / hda1 create a filesystem type linux ext2 on hda1 partition
mke2fs -j / dev / hda1 create a linux ext3 (journaled) on hda1 partition file system
mkfs -t vfat 32 -F / dev / hda1 create a FAT32 file system
fdformat -n / dev / fd0 a formatted floppy
mkswap / dev / hda3 create a swap file system
SWAP file system
mkswap / dev / hda3 create a swap file system
swapon / dev / hda3 enable a new swap file system
swapon / dev / hda2 / dev / two swap partitions hdb3 enable
backup
full backup dump -0aj -f /tmp/home0.bak / home make a '/ home' directory
dump -1aj -f /tmp/home0.bak / home interactive making a backup '/ home' directory
restore -if /tmp/home0.bak interactive restore a backup
rsync -rogpav --delete / home / tmp synchronization sides directory
rsync -rogpav -e ssh --delete / home ip_address : / tmp SSH channel through the rsync
the rsync -e ssh --delete -AZ ip_addr: / Home / public / Home / ssh by local compression and synchronization to a remote directory local directory
rsync -az -e ssh --delete / home / local ip_addr: / home / public via ssh and compression to a local directory to a remote directory synchronization
dd bs = 1M if = / dev / hda | gzip | ssh user @ ip_addr 'dd of = hda.gz' on the remote host via ssh perform a backup operation of a local disk
dd if = / dev / sda of = / tmp / file1 backup content to a disk file
tar -Puf backup.tar / home / user make a incremental backup of 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 on remote directory via SSH
(the tar C / Home) | -C SSH User @ ip_addr 'CD / Home / Home Backup && the tar-X -p 'copy remote directory via ssh in a local directory
tar cf - | (cd / tmp / backup; tar xf -). the local copy a directory to another, preserving permits and links to
find / home / user1 -name '* .txt' | xargs cp -av --target-directory = / home / backup / --parents to find and copy all '.txt' file that ends from one directory to another
find / var / log -name '* .log' | tar cv --files -from = - | bzip2> log.tar.bz2 finds all '.log' The end of the file and make a bzip package
dd if = / dev / hda of = / dev / fd0 bs = 512 count = 1 to make a copy MBR (Master Boot Record) content to a floppy disk operation
dd if = / dev / fd0 of = / dev / hda bs = 512 count = 1 resume MBR from backup saved in floppy
disc
cdrecord -v gracetime = 2 dev = / dev / cdrom -eject blank = fast -force emptying the contents of a rewritable optical disk
mkisofs / dev / cdrom> cd.iso Creating a disc on your disk iso image file
mkisofs / dev / cdrom | gzip> cd_iso.gz create a compressed disk in the CD iso image file
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 burn an ISO image file
gzip -dc cd_iso.gz | cdrecord dev = / dev / cdrom - burn a compressed ISO image
mount -o loop cd.iso / mnt / iso mount an ISO image
cd-paranoia -B transcription from a CD-ROM tracks to wav file
cd-paranoia - "- 3 'transcribed from a CD-ROM tracks to wav file (parameter -3)
cdrecord --scanbus scan bus to identify the channel scsi
dd if = / dev / hdc | md5sum md5sum encoding a verification apparatus, for example, a CD
Network - (Ethernet and wireless WIFI )
the ifconfig eth0 show configuration of an Ethernet card
ifup eth0 enable one interface 'eth0' device
ifdown eth0 a disable interface 'eth0' device
ifconfig eth0 192.168.1.1 netmask 255.255.255.0 IP address control
ifconfig eth0 promisc provided 'eth0' promiscuous mode packet sniffing (sniffing)
dhclient eth0 to dhcp mode is enabled 'eth0'
route -n Show the Table routing
route the Add 0/0 -net default gw IP_GATEWAY configura Gateway
route the Add -net 192.168.0.0 Netmask 255.255.0.0 gw 192.168.1.1 the configure static route to the REACH Network '192.168.0.0/16 '
route del 0/0 GW IP_GATEWAY Remove static route
echo ". 1"> /proc/sys/net/ipv4/ip_forward activate ip routing
hostname show hostname of system
host www.example.com lookup hostname to resolve name to ip address and viceversa
nslookup www.example.com lookup hostname to resolve name to ip address and viceversa
ip link show show link status of all interfaces
mii-tool eth0 show link status of 'eth0'
ethtool eth0 show statistics of network card 'eth0'
netstat -tup show all active network connections and their PID
netstat -tupl show all network services listening on the system and their PID
tcpdump tcp port 80 show all HTTP traffic
iwlist scan show wireless networks
iwconfig eth1 show configuration of a wireless network card
hostname show hostname
host www.example.com lookup hostname to resolve name to ip address and viceversa
nslookup www.example.com lookup hostname to resolve name to ip address and viceversa
whois www.example.com lookup on Whois database
JPS Tools
jps (Java Virtual Machine Process Status Tool) is a java all current process pid command displays JDK 1.5 provides a simple and practical for on linux / unix platform is simple look at some of the current simple cases java process.
I think many people are unix systems used in the ps command, which is mainly used to display the current progress of the case system, which processes and their id. jps is the same, its role is to display the current system java process, and id number. We can use it to see in the end we launched several java process (since each program will be exclusively a java java virtual machine instances), and their process ID (to prepare for the next several procedures), and can be viewed through opt Details startup parameters of these processes.
Usage: In the current fight jps command line (requires JAVA_HOME, not, change to the directory program play).
jps stored in JAVA_HOME / bin / jps, in order to facilitate set the JAVA_HOME / bin / is added to the Path use.
$> jps
23991 Jps
23789 BossMain
23651 Resin
More commonly used parameters:
-q Displays only the pid, does not display the class name, jar file name and arguments passed to the main method of
$> JPS -q
28.68 thousand
23789
23651
-m output parameters passed to the main method, in the embedded jvm may be null
$> jps -m
28715 Jps -m
23789 BossMain
23651 Resin -socketwait 32768 -stdout /data/aoxj/resin/log/stdout.log -stderr /data/aoxj/resin/log/stderr.log
jar file full path name -l output of the application main class or the full name of the application package
$> jps -l
28729 sun.tools.jps.Jps
23789 com.asiainfo.aimc.bossbi.BossMain
23651 com.caucho.server.resin.Resin
-v output parameters passed to the JVM
$> jps -v
23789 BossMain
28802 Jps -Denv.class.path=/data/aoxj/bossbi/twsecurity/java/trustwork140.jar:/data/aoxj/bossbi/twsecurity/java/:/data/aoxj/bossbi/twsecurity/java/twcmcc.jar:/data/aoxj/jdk15/lib/rt.jar:/data/aoxj/jd
k15/lib/tools.jar -Dapplication.home=/data/aoxj/jdk15 -Xms8m
23651 Resin -Xss1m -Dresin.home=/data/aoxj/resin -Dserver.root=/data/aoxj/resin -Djava.util.logging.manager=com.caucho.log.LogManagerImpl -
Djavax.management.builder.initial=com.caucho.jmx.MBeanServerBuilderImpl
Sudo jps see the number of the most complete process
jps 192.168.0.77
All examples listed jvm 192.168.0.77 remote server machine, using rmi protocol, default port 1099
(Provided that the remote server jstatd service)
Note: jps command has a very bad place, it can only display the current user's java process, to be displayed to other users or only with unix / linux ps command.
Transfer: https://www.cnblogs.com/yjd_hycf_space/p/7730690.html
For details, see the official documentation sun.
http://java.sun.com/j2se/1.7.0/docs/tooldocs/share/jps.html