Các Lệnh Cơ bản trong CentOS 6 – phần 1

1.useradd – Lệnh tạo User hoặc chỉnh sửa thông tin User.

Cú pháp useradd <user name>

Các lệnh  tùy chọn với  useradd

 

-s the login shell for the new user account

# useradd -s /sbin/nologin user

-d home directory for the new user account

# useradd -d /home/user user

-g force use GROUP for the new user account

# useradd -g group user

-e set account expiration date to EXPIRE_DATE

# useradd -e 20081231 user

-u force use the UID for the new user account

# useradd -u 550 user

-m create home directory for the new user account

# useradd -m user

-M do not create user’s home directory(overrides /etc/login.defs)

# useradd -M user

2. passwd – dùng để tạo password chứng thực cho user

Cú pháp passwd<usernam>.

Các lện tùy chọn với  passwd

-d This is a quick way to disable a password for an account

# passwd -d user

-l This option is used to lock the specified account and it is available to root only

# passwd -l user

-u This is the reverse of the -l option – it will unlock the account password by removing the ! prefix

# passwd -u user

-x This will set the maximum password lifetime, in days, if the user’s account supports password life-times

# passwd -x 10 user

-n This will set the minimum password lifetime, in days, if the user’s account supports password life-times. Available to root only

# passwd -n 10 user

-i This will set the number of days which will pass before an expired password for this account will be taken to mean that the account is inactive and should be disabled, if the user’s account supports pass-word lifetimes

# passwd -i 10 user

-w This will set the number of days in advance the user will begin receiving warnings that her password will expire, if the user’s account supports password lifetimes

# passwd -w 10 user

-S This will output a short information about the status of the password for a given account

# passwd -S user

user PS 2009-09-12 0 99999 7 -1 (Password set, MD5 crypt.)

3. exit- dùng để kết thúc phiên làm việc

4.su-dùng để chuyển tới user

cú pháp us – <user name>

5. usermod- dùng để tùy chỉnh user account.

cú pháp usermod -<tùy chọn><user name>

-d new home directory for the user account
-g force use GROUP as new primary group
-G new list of supplementary GROUPS
-s new login shell for the user account
-u new UID for the user account
-L lock the user account
-U unlock the user account

6. vi- lệnh cho phép chỉnh sửa

cú pháp vi <file>

tùy chọn với lệnh vi.

chuyển đổi  Command mode/Input Mode

Key Description
i insert words on the Cursor position
a insert words after the Cursor position
I insert words on the head of the line of Cursor position
A insert words on the last of the line of Cursor position
o insert words on the empty line inserted that is after Cursor position
O insert words on the empty line inserted that is before Cursor position
[Esc] switch to command mode

Lưu và thoát.

Key Description
:w save
:w file save as a file
:q quit without saving(confirmed)
:q! quit without saving(forcely)
:wq save and quit
:e back to the last saved
:n switch to other file if some files are opened
:r file read content of a file on current line
:n,mw file save as a file from n line to m line
:n,mw>>file add to a file from n line to m line

Điều khiển con trỏ

Key Description
h (or) [←] move to left
l (or) [→] move to right
k (or) [↑] move to above
j (or) [↓] move to below
w move to the head of next word
b move to the head of previous word
0 move to the head of line
$ move to the last of line
G move to the last line
nG move to n line
H move to the head of current screen
nH move to n line on current screen
L move to the last line on current screen
nL move to the line of “n”
M move to the head line on current screen

Điều khiển thanh cuộn

Key Description
[Ctrl] + f scroll down for a screen
[Ctrl] + b scroll up for a screen
[Ctrl] + d scroll down for half of a screen
[Ctrl] + u scroll up for half of a screen

Điều khiển chỉnh sửa.

Key Description
x delete a word on cursor
X delete a word before cursor
yy copy the current line into the buffer
y$ copy from the cursor position to the end of the line into the buffer
y0 copy from the head of line to the cursor position into the buffer
yw copy a word on cursor into the buffer
p paste the contents of the buffer after the cursor position
P paste the contents of the buffer before the cursor position
dd delete the current line
d$ delete from the cursor position to the end of the line
d0 delete from the head of the line to the cursor position
dw delete from the head of the line to the next word
u cancel the last operation
U cancel the last operation for a line

Điều khiển tìm kiếm.

Key Description
/ word [Enter] search a word from the head of a file to the end
? word [Enter] search a word from the end of a file to the head
n search next after a result of searching

7.Newaliases- lệnh dùng để cấu hình thay đổi

8.chkconfig- truy vấn và cập nhật thông tin services.

cú pháp chkconfig <services>