Linux command
1.type: View command is an internal command or external command
eg: type cd
eg:type ifconfig
2.tab key: automatically filled
3. backslash "\": to force line breaks
Quickly delete all the characters before the cursor: 4.ctrl + U
5.ctrl + K: quickly delete all characters following the cursor
6.ctrl + Y: Paste character just deleted
7.ctrl + L: clear screen
8.ctrl + C: to end the current command
9.ctrl + D: User Exit
10.ctrl + A: Move the cursor to the first line
11.ctrl + E: Move the cursor to the end of the line
12.ctrl + Z: into background
13.ctrl + R: Find command history
* Page shift + PgUp / Dn in a virtual machine
Internal 14.help Command Help
eg: help cd
eg:ls --help
15.man line help (Baidu is more convenient) quit with q
16.ls: displays a list of files and directories in the directory, a combination of different options to achieve different role (ls option empty empty directory or file name)
-l: Displays a list of files and directories in long format
-a: shows all subdirectories and files information
-A: with -a, does not display the hidden directory "and ..."
-d: display directory attributes, often at the same time with the -l use ls -ld
-h: more user-friendly display the directory or file size, often with the use ls -l simultaneously -lh
-R: display the contents of a directory and all subdirectories recursively
17.du: Display files or share disk space (du options empty empty directory or file name)
-a: Statistics all files, not just directories
-s: only count the total size
h: Display Size
18.touch: Create a file (touch empty file name) (Creates multiple files touch an empty file name {1..100} .txt)
19.mkdir: Create a directory (mkdir empty empty directory location and name of the option)
-p: Disposable create nested multi-layer directory
-v: Show
-m: Set umask value
20.cp: Copy the file or directory (cp option empty empty source file or directory target file or directory)
-f: covering the same name as the file or directory, force replication
-i: to remind the user to confirm
-p: keep the source file permissions, attributes, owner and time markings unchanged
-r: recursive copy
21.rm delete a file or directory
-f: without prompting forced to delete
-i: prompt the user to confirm
-r: recursive directory delete the entire number
22.mv move (mv option empty empty source file or directory target file or directory)
23.which linux command to find the location where the program (which the null command / program name)
24.find: Fine locate a file or directory (find Find Look conditional expression)
-name Find by name (find / etc -name "resol * conf")
-size by size to find (find / etc -size + 1M)
-user by attribute to find (find / etc -user root)
-type find by type (find / boot -type d) [d: directory; f: common file; b: block device; c: character device file]
Logical operators and -a -o
find /boot -size +1M -a -name"vm*"
find /boot -size +1M -o -name"vm*"
/ Root administrator's home directory
/ Home general user's home directory
/ Boot file system kernel boot
/ Dev Device, the device file (in yellow)
/ Etc configuration files
/ Bin position command exists
/ Sbin administrator can perform commands (chmod modify file permissions)
/ Usr applications usr / local
/ Var log files, recording system using state (important files in the directory / var / log were picked the wrong treatment services through the log)
25. The view file contents cat, tac, nl, more, less, head, tail
View from the top cat file contents (cat file name)
-n line number display content displayed simultaneously cat -n = nl
-A displays all characters
eg: cat -A /etc/yum.conf
tac view the file contents from the bottom up
eg: tac -that /etc/yum.conf
nl view also shows the number of rows
eg: nl /etc/yum.conf
more split-screen display file contents
eg: more /etc/passwd
(Enter scroll down one line, scroll down one line space q to quit)
less powerful split-screen display file contents
(Press PgUp, PgDn flip up and down)
head to view the file contents of the first ten lines
eg: head -5 /etc/passwd
After ten lines of tail view file contents
eg: tail -5 /etc/passwd
26.wc statistics file (-l count lines -w number of words, -c number of bytes)
eg: wc /etc/hosts
ls / etc / | (number of files in a directory view) wc -l
27.grep, egrep search and filtering
grep: Find the file and displays the lines containing specified string (grep search criteria target file)
Find -i ignore case when
-v reverse line does not match the look, output and Conditions
( "^ ..." represents the beginning ... "... $" means ending ... "^ $" denotes an empty line
eg:grep "ftp" /etc/passwd
eg: grep -v "^#" /etc/yum.conf | grep -v "^$"
egrep: Enhanced filter (egrep "search conditions 1, 2 search criteria, the search criteria 3 ..." target file)
eg:egrep -v "^# | ^$" /etc/yum.conf
28.gzip, gunzip, bzip2, bunzip2 compression and decompression (only a single compressed file)
(1-9 compression options for the digital control of compression level, the higher the level the greater the number, the compression format is .gz, .bz2)
eg:bzip2 test.txt gunzip text.txt.gz
29.tar archive command (Preparation archive, the archive release) {tar -cf archive file name of the source file or directory archive} {tar -xf target directory name} -C
-c create .tar archive format
-x Extract the package .tar format
-v output Details
-f unpacked to the specified folder
Preserve the original file and directory permissions when -p package
-t list to view the files in the package
Released when the specified destination directory unpacked -C
-z call gzip compression or decompression program
-j call bzip2 compression or decompression program
Retention of files and directories when -P package absolute path
(Former option can be omitted tar command "-", when extracting need to select "the -Z" or "-j" self-identification command)
eg:mkdir -pv /aaa/bbb/ccc
tar cjvf aaa.tar.bz2 / aaa /
eg: tar xf aaa.tar.bz2 -C / root /
30. vi text editor (create or modify a text file maintenance Linux in a variety of configuration files)
vim: enhanced version of the vi editor, it is customary also called vi
a content inserted after the cursor
A cursor line is inserted at the end of the content
i Inserts from before the cursor
l In the first trekking cursor Inserts
o empty row is inserted at the cursor
O empty row is inserted in the current cursor
PgUp up an entire page flipping
A full page flipping down PgDn
Home to jump to the beginning of the line
End jump to end of the line
Gg 1G or jump to the first line of the file
Jump to the end of the line Q G member
#G jump to the first file line #
: Set nu line numbers displayed in the editor
: Set nonu cancel the line numbers in the editor display
dd delete the current cursor line
#dd delete # rows content starting from the cursor line
U cancel all edits made to the current
ZZ save the current file and exit the vi editor
: W save the modified contents
: W / root / newfile save as another file
: Q unmodified quit
:! Q abandon changes to the contents of the file and exit vi
: Wq to save and launch
wq! forced to save and exit
Undo recovery ctrl + r
: R / etc / filesystems read other file content in the current file
: S / old / new current line to find the first character "old" replaced by "new"
: S / old / new / g in the current line to find all the strings "old" replaced by "new"
: #, # S / old / new / g replacing the row number "# #" of the extent of the string "old" to "new"
:% S / old / new / g replaces all "old" in the entire file is "new"
: S / old / new / c c in the alternative command added to the end of the command, each one action will prompt the user for confirmation
supplement
: X save and exit, but if not modified, the time stamp change
: W file Save the file as the current file (vim)
: X encryption (vim)
: 7 Jump to the seventh row
: 1, $ co $ from the first row to the last row to copy, to the last line after
J merge the current line and the next line
ctrl + r u command to undo operation using the recovery
31.rpm package installation, software installation package format
rpm -q suboption Software name
-qa View all RPM packages installed table
-qi view details specified software
-ql query package installation directory, a list of files
-qf query file or directory belongs to which software RPM
-qp to query the RPM package file is not installed
-qpi: View the details of the software
-qpl: View directory contained in the package, the file list
eg: rpm -q bash
eg: rpm -qa | grep bash (query whether there bash package installed)
eg: -ql postfix (postfix query the list of files installed by the package) rpm
eg: rpm -qf / usr / bin / vim (vim inquiry which was installed by the package)
eg: rpm -qpi ethtool-3.5-1.el6.x86_64.rpm
eg: rpm -qpl ethtool-3.5-1.el6.x86_64.rpm
Install software upgrades RPM (rpm RPM package file)
-i install a new package
-U upgrade, if not installed, install
-h with "#" sign shows the installation progress
-v show details during installation
Rpm -F a software update, if not installed, abort the installation
--force force the installation package rpm specified (usually not)
RPM uninstall software (rpm -e name of the software)
--nodeps install, upgrade or uninstall the software, ignoring dependencies (usually not)
eg: rpm -e lynx (unloading Lynx)
rpm -q lynx (View)
Rebuild the RPM database
rpm --rebuilddb
rpm --initdb
32. Construction of local yum repository
umount / dev / sr0 unload the disc
mkdir / media / cdrom establish the optical drive is mounted directory
mount / dev / sr0 / media / cdrom to mount the CD / media / cdrom
cd /etc/yum.repos.d/ move to the directory where the yum source configuration file
mkdir bak establish redundant backup directory of the source file
mv C * bak beginning to move files to the backup directory of C
Establish yum source profile vi local.repo manual, document reads as follows
yum source configuration file:
[cdrom]
name=cdrom
baseurl = file: /// media / cdrom
enabled=1
gpgcheck=0
Save and exit
yum yum -y clean all Clear Cache
yum yum makecache rebuild cache
Installation: yum -y install
Delete: yum -y remove
Upgrade: yum -y update -y: do not interact
33. A source code compiler installation
Install gcc gcc-c ++
make install gcc gcc-c++
unzip
tar xf httpd-2.2.17.tar.gz -C /usr/src
Preconfigured
cd /usr/src/httpd-2.2.17/
./configure --prefix=/usr/local/apache
Compile
make
installation
make install
Compile and install steps
After the backup, modify the configuration file (line number # 97 removed)
cd /usr/local/apache/conf/
cp httpd.conf httpd.conf.bak
we /usr/local/apache/conf/httpd.conf
Start Apache
/usr/local/apache/bin/apachectl start
yum -y lynx (text browser)
lynx 127.0.0.1
34. The user accounts file / etc / passwd (save the user name, basic information about the host directory, login shell, etc., each row corresponds to a user account records
tail -1 /etc/passwd
The first field: user account name
The second field: x password placeholder
The third field: uid (user ID)
Fourth field: gid (Group ID)
The fifth field: User Notes
Sixth field: the user's home directory
Seventh field: login shell (if it is / sbin / nologin can not log in)
35./etc/shadow save the user's password, account expiration date information, each row corresponds to a user's password records
tail -1 /etc/shadow
The first field: user account name
The second field: ciphertext (password)
The third field: Last Modified account the number of days elapsed from 1970.01.01
Fourth field: from the number of days since the last password change can not change your password again, free to modify represents 0 days
The fifth field: the number of days the password expires (after modifying the password must be re-modify the number of days, permanent representation 99999 can be used)
Sixth field: mandatory password change reminder time (7 indicates the start of a warning before the password expires 7 days)
Seventh field: When the password expires after the number of days the account is disabled
Eighth fields: account expiration date, it appears as if the set number of days from the expiration date 1970.01.01
36. Add user account useradd username
-u uid designated tag number
-d specifies the home directory, default default is / home / user
-e account designated expiry time
-M does not create the home directory for the user to initialize
-s specifies the user's login shell
-g Specifies the group name or the user's basic gid number
-G specify additional user group name or gid number
-c add notes, displayed in the / etc / passwd fifth field
37. The initial user account profiles
~ / .Bash_profile executed each time landing
~ / Execute at the start of a new shell .bashrc
~ / .Bash_logout each execution time from landing
Specific steps
Create a user useradd wjj
vi ~ wjj (username) /. bash_profile
(Editor to write the last line echo "welcome wjj!", Save and exit)
View empty wjj - with empty su
V ~ wjj / Kbsharc
(Editor to write the last line echo "hi! This is a new bash!" Save and Exit)
With su air - air wjj view (among users, exit the user enters can see)
you ~ wjj / .bash_logout
(In the last line editor to write echo "bye bye wjj!")
38. passwd to change user password settings (passwd user name)
-d clear the user password
-l Lock user accounts
-S View user's account status (is locked)
-u unlock user accounts
-x plus numbers, passwords longest active time
-n plus numbers, passwords shortest effective time
-w plus the number, number of days before the password expires began to remind users
-i digital plus, when the password expires after the number of days the account is disabled
39. usermod modify user attributes (usermod username)
-l: change user account name (usermod -l new name of the old name)
-c: Modify User Remarks
-L: Lock user accounts
-U: unlock user accounts
40. userdel Delete user
-r delete a user deletes a user's home directory
41. groupadd groupadd Add a group account management account name
groupadd -g 888 digital account name
42.gpasswd setting group account password, add, delete group members
-a add a user into the group
-d remove a user from the group
-M defined list of group members, separated by commas
43. groupdel delete group accounts groupdel group account name
44. id, groups, finger, w, whoami, who query
Id user name (user query represented)
groups user name (the main query client belongs)
finger user name (query account details) need to install yum built warehouse equipment
w query is logged on to a host of user information
whoami query account name currently logged in
who (similar to the w command to query the user has logged on to the host)
-: Indicates a general file
d: represents the directory
l: represents a soft connection
p: represents PIPE pipe file
s: indicates socket communication socket file
c: The character device file
b: a block device file
Each letter of permission and octal
Read permission r 4
Write permissions w 2
Executable x 1
No permission - 0
45. chmod settings file or directory permissions
-R represents permissions recursively set all the subdirectories and files in the directory and directory
u owner
g is a group
o others
everyone a
+ Add
- Delete
= Reset
46. The new directory can be set directly with the -m option when you create the directory permissions
Set file ownership chown
chown owner file
chown: is a group of files
chown owner: is a group file
47. umask permission mask
Umask setting value (umask 020)