Linux System Command Basics

Source: Internet
Author: User
Tags clear screen save file

After installing the Linux system View/directory,/The following directory functions as follows:

/Under Directory function
/bin/usr/bin/usr/local/bin Normal User executable directory
/sbin/usr/sbin/usr/local/sbin System Executable Directory
/etc/Configuration file Directory
/usr/application Directory
/var/Server Data Directory
/lib/usr/lib/usr/local/lib Library file directory (System module)
/dev/block device directories and character devices
/boot bootstrapper directory (kernel, boot file, boot program)
/root Administrator Home Directory
/home directory for ordinary users
/proc Memory Information directory (memory information and process information) pseudo file system
/sys Memory Information directory (memory information and process information) pseudo file system
/tmp Temp file directory
/OPT Third party software catalog
/mnt temporary hanging at the point
/srv Server Data Directory
/media Media Directory
/miscautofs
/netautofs
/TFTPBOOTTFTP Service Use
/selinux SELinux Use
/lost+found for file System Recovery

Linux Common commands

Ctrl+l Clear Screen
CTRL + C Interrupt

[Basic command]

Ls-l Install.log
-:rw-r--r--: 1:root:root:39410:2013-05-21:install.log
File type: Permissions: Hard Link Number: Owner: Owning group: File size: Last modified: File name
-Normal file
D catalog File
C Character file
B-Block device files
L Soft link file (symbol)
P Pipeline File
s socket file

Ls-l long Format-a all files-a all files except. and.
. Current directory
.. Upper Directory
-D Display directory information-H max units Display-T-time sort
-R Reverse-R recursion

1.ls--help
2.info ls
3.type ls
Alias La= ' Ls-la '
Unalias LA
4.man ls
A user command
Two system calls
Three-Library call
Four Special documents
Five configuration files
Six games
Seven Miscellaneous (man)
Eight system commands
Nine cores reference

Makewhatis Maintenance man Backstage
Man-f passwd query commands are described in those chapters
Man-k passwd Fuzzy Query

CD CD/.. .. /.. . ~-Return to last working directory
PWD Query Location

View File Contents

1.head

Head-n Install.log

2.tail

Tail-n Install.log

Tail-f/var/log/messages

3.more

More Install.log

4.less

Less Install.log

5.cat

Cat-n Install.log

Cat-b Install.log

Cat-n Install.log | Less

| Pipe symbol

The previous command output is entered as the last command

Create a file

Touch

Touch Aa.txt

Touch Cc.txt Tt.txt

Touch Abc{1..10}.txt

Touch {A,b,c}{1..3}.txt

Create a Directory

Mkdir

mkdir TT

mkdir test1 Test2

mkdir abc{1..10}

Mkdir-p DIR/AA

MKDIR-PV DIR/AA

Copy copy cut move

cp/root/install.log/tmp/

Simultaneous renaming of cp/root/install.log/tmp/install copies

Cp-r/tmp/dir//

mv/root/xx.txt/tmp/

Mv/root/xx.txt/tmp/haha.txt

MV Xx.txt Xx.txt.bak

MV/TMP/TT/

Delete

RmDir only empty directories can be deleted

Rm

RM tt.txt

Rm-f Install.log

RM-RF ABC9

RM-RF *.txt

RM-RF abc*

rm-rf/dir/

Vim Text Editor VI
Command mode enters input mode
A current character followed by input
A Current Line End input
I current character before input
I Current Line Header input
o The next line of input for the current row
O line input on the current row
s to delete the current character after entering
S to delete the current line after entering

Home keys beginning end Line end

Command mode
U undo one-Step operation
CTRL + R Redo

YY Copy a row
50yy Copy 50 rows
DD Cut one line DD Delete
50DD Cut 50 lines

P Paste

W The first character of the next word
DW Delete/cut a word yw

^ Beginning d^ y^
$ line Tail d$ y$

G-Tail Line
GG First Line
750G positioning to 750
DGG delete the current line to the first row
DG Delete current line to tail line

Last-line mode
: w:q: Wq
: w! : q! : wq!
: E/root/aa.txt Open/Read in
: 2,3w/root/newfile.txt Save
: R/root/file.txt Append Read-in
: e! Re-read into the current file

: Set NU Displays line number
: Set Nonu Remove line number
: Set Autoindent auto-close
: Set noautoindent Remove auto-shrink

Find
/From Top down
? From bottom to top
n N

Replace
:%s/ab/oo/gc% All rows g global s replace C Interactive replace
2,5s/ab/oo/gc

:%s/^\t//replaces all start indicator characters
:%s/\t//replaces the first indicator of each line
:%s///g Remove all spaces
:%s/^#//g Delete the beginning of the line

: g/^$/d Delete Empty lines
: g/^\s*$/d Delete all types of empty rows

: X Encryption decryption

Vim configuration file/ETC/VIMRC

Multi-file operation
Vim Aa.txt cc.txt Tt.txt
: Args Next prev First Last ctrl+6

Vimdiff aa.txt cc.txt Tt.txt
Ctrl+w+w

Vim-o aa.txt tt.txt Cc.txt
Vim-o aa.txt tt.txt Cc.txt

Vim Tutorials
/usr/share/vim/vim70/tutor/tutor.zh.euc

Gedit/usr/share/vim/vim70/tutor/tutor.zh.euc
File---> Save----> Character Set-----> Save-----> Replace
Vimtutor

Iconv-f gb18030-t utf-8 tutor.zh.euc-o test.txt
Character encoding Conversion

Shift+k

Visual Mode V
Y copy d remove p paste
Visual Block mode Ctrl + V
Shift+i-----> Input character-->esc (two times)

User Management
UID 0 rootgid 0 Root
UID 1-499 system GID 1-499 System Group
UID 500-60000 user GID 500-60000 Group

Add User Useradd
Useradd ABC1

Files to save user information:/etc/passwd
Robin:x:500:500:ptuser:/home/robin:/bin/bash
User name: Password placeholder symbol: Uid:gid: Description: Home directory: Shell

Useradd-u 1000-g 500-c hello-d/mnt/abc2-s/bin/bash ABC2

Add Group Groupadd
Groupadd uplooking

File to save group information/etc/group
uplooking:x:502:
Group name: group Password placeholder: GID: Username
Groupadd-g Upup

Set Password
1.root via passwd Robin
2.robin Execute passwd Modify your password

Password Save file:/etc/shadow
Robin:$1$bj0exbfx$e24mczi0jmsidr:15847:2:10:3:2::

First column: User name
Second column: password (MD5)
Third column: Password last modified (days)
Fourth column: Minimum password time
Fifth column: Password maximum time (password validity period) (days)
Sixth column: Warning time before password expires
Seventh column: Password expiration payback date
Eighth column: Account validity
Nineth column: Reserved columns

Practice:
1. Add group KKK GID is 1500
Groupadd-g KKK
2. Add user Zorro UID 1500 belongs to KKK group description: Hello home directory/mnt Shell:bash

Useradd-u 1500-g kkk-c hello-d/mnt/zorro-s/bin/bash Zorro

3. Set the user password to 123 through the administrator
Terminal login Zorro set its own password to 123.com


Modify user Information
Usermod
Usermod-u-g-c-d-s Robin

Usermod-l ABC2ABC ABC2
Usermod-l Robin
Usermod-u Robin
usermod-f Password expiration Payback expiration time
USERMOD-E Account Expiration Date

Modify group Information
GROUPMOD-G 2500 uplooking
Groupmod-n Upup uplooking

Change Password and information
Passwd-n (minimum time)-X Max Time-W warning Time-I password expires payback number expires

Passwd-l Robin Lock Password
Passwd-u Robin unlock Password
Passwd-s Robin View password status

Add a user Tom and Jerry set two user password to 123 respectively
Lock Tom account lock Jerry Password
is the return value of the terminal login test consistent?
See Shedow files Two users what's the difference?
! Lock Account
!! Lock password

To delete a user:
Userdel-r ABC2
Delete a group
Groupdel Upup


Additional groups
Groupadd yw
Groupadd KF
USERADD-G KF,YW WG Overlay additional Group information
Useradd-a-G KF,YW WG Append additional group information

Groupadd boss
GPASSWD boss

Add an account manually
# # # # #1 Groupadd zu
1). Vim/etc/group
zu:x:2000:

##### #2. Useradd-g zu ZHB
1). vim/etc/passwd
Zhb:x:2000:2000::/home/zhb:/bin/bash
2). MKDIR/HOME/ZHB
3). cp/etc/skel/.bash*/home/zhb/

# # # # #3 passwd ZHB
1). Vim/etc/shadow
Zhb::15848:0:99999:7:::
2). Grub-md5-crypt generates a password to copy the password to the second column

Terminal login Test Create file?


Multi-User Import
1. The user and system passwd file user information in the import file (user.txt) does not conflict
2. User cannot conflict in import file (User.txt)

[email protected] ~]# cat User.txt
User1:x:3000:3000:ptuser:/home/user1:/bin/bash
User2:x:3001:3001:ptuser:/home/user2:/bin/bash

NewUsers < User.txt

[email protected] ~]# cat Passwd.txt
User1:123
User2:123

CHPASSWD < Passwd.txt

User Configuration Files
/etc/default/useradd
Home=/home
Shell=/bin/bash
Skel=/etc/skel

/etc/login.defs (limit UID number password limit)

Linux System Command Basics

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.