Linux basic Commands (ii)

Source: Internet
Author: User

Continue to share with you today (take the previous chapter)

(+) Vim + file name (edit file, if the file does not exist also can be edited, but must be saved, the use of vim alone is open vim manual, the same can be edited

Text, but save it before you exit. Shift+:w (space)/path/file name)

(grep-v) + keywords (filter out lines that don't contain keywords)
Other usage: Good to speak here (http://blog.51cto.com/silgon/204579)
($) file + Directory/file name (view file properties)

[[email protected] boke]# lsa  a1b  b  c  file  file1  no  

(strings) +data type file (view data type file, format is not very good)

[[email protected] boke]# file/var/log/wtmp/var/log/wtmp:data[[email protected] boke]# cat/var/log/wtmp (This view will be garbled) ~~~reboot2.6.32-431.el6.x86_64?? 5~~~runlevel2.6.32-431.el6.x86_64? 155~~~runlevel2.6.32-431.el6.x86_64p°?*~,.tty33login,.p°?.. Tty44login. P°?*.tty22login*.p°?0.tty55login0.p°?8.tty66login8.p°?? Tty7:0ding:0??                                                                                                                       $+?pts/0/0ding:0.0p?ts/0/0ding ?? (§apts/4ts/4ding192.168.1.1387?d J Pts/1 soft Z0 pts/2??: 0apts/3z-?1σpts/1ts/1ding192.168.1.138-6?3§apts/4{j? pt S/2ts/2ding192.168.1.138k?σpts/k??                                                                                                                                                             ppts/1ts/1ding192.168.1.138            tty1:0ding:0,?? ? pts/1/1ding:0.05??? fpts/2ts/2ding192.168.1.138 (pts/0 (? W cheek pts/0ts/0ding192.168.1.138.?? fpts/2r?npts/0rfpts/0ts/0ding192.168.1.138+?b/([[email Protected] boke]# Xshellxshellx-bash:xshellxshellx:command not found[[email protected] boke]# strings/var/log/ Wtmp Reboot2.6.32-431.el6.x86_64runlevel2.6.32-431.el6.x86_64runlevel2.6.32-431.el6.x86_64tty3login

(shutdown) (Shutdown, restart command)
-H Now (shut down immediately)
-R Now (restart immediately)
(Poweroff,reboot) (also shutdown, restart)
(hostname) (View host name)

[[email protected] boke]# hostname localhost.localdomain

Who (view current users online)

[[email protected] boke]# whoding     pts/0        2018-04-19 13:39 (192.168.1.138)ding     tty1         2018-04-19 10:30 (:0)ding     pts/1        2018-04-19 10:30 (:0.0)

(to) ll--full-time (show verbose time)
[email protected] boke]# ll--full-time

total 24drwxr-xr-x. 3 root root 4096 2018-04-18 13:03:57.061996611 +0800 a-rw-r--r--. 1 root root    0 2018-04-18 12:58:46.195998792 +0800 a1bdrwxr-xr-x. 2 root root 4096 2018-04-18 13:02:36.033996833 +0800 b

(mkdir) with touch (illustration)

[[email protected] boke]# mkdir {1..3}[[email protected] boke]# touch {1..3}/lizi{1..3}[[email protected] boke]# tree ..├── 1│?? ├── lizi1│?? ├── lizi2│?? └── lizi3├── 2│?? ├── lizi1│?? ├── lizi2│?? └── lizi3├── 3│?? ├── lizi1│?? ├── lizi2│?? └── lizi3

(Type,man,--help,info,help,/usr/share/doc) (all Help commands)
Type: Determines whether the command is external or internal
Help: How to use internal commands
--help: How to use external commands
Man: command usage, config file (man has 8 chapters, default first chapter, to see Configuration file using Man

5 + files/generally stored in/usr/share/doc)
/usr/share/doc: Storing software help documentation
Info: Method, config file (too detailed ... )

Date (time, time interval is too large, may cause login not on the machine)
-S (Modification time, "Month Day + tick seconds" must be added with double quotes)
(TZSELECT,TIMEDATECTL) (6 system View modify time zone, 7 system view modify time zone. These all belong to the system time)
(Hwclock) (Hardware time)
(hwclock)--hctosys (Hardware time synchronization system time) Hwclock--SYSTOHC (System time synchronization hardware time)
Cal (see Calendar, enter month/year later)

Users and Groups

      1.相关文件    (1)passwd-----用户信息    (2)shadow----用户密码策略    (3)gshadow------组密码策略    (4)default/useradd------创建用户时的一些参数    (5)group-----组的信息    (6)shells-----当前支持的bash(命令解释器)    (7)skel------家目录默认参考文件    (8)login.defs-----创建用户时密码策略,权限等默认参数    *以上文件全部在/etc目录下

[Email protected] boke]# VIM/ETC/PASSWD

root:x:0:0:root:/root:/bin/bash
Above: For the separation of this representative (user, password placeholder, uid--user unique identifier, GID---Group unique identifier, user description information, user home directory, user-used

Shell

[Email protected] boke]# Vim/etc/shadow

root:$1$Aj.ZRFcN$mt8l5V.YExG0HtFPb7iWo/:17632:0:99999:7:::
The above: For the separation of this representative (user, encrypted password, the last time to change the password---from 1970-1-1 onwards how many days, password minimum validity period, password the longest

Validity period, the password expires a few days before the warning, password expiration date grace days to change, account expiration date, reserved bit)

[Email protected] boke]# Vim/etc/group

root:x:0:
The above: As a separate this representative (group name, group password placeholder, GID, members of the group---, as delimited)

[Email protected] boke]# Vim/etc/gshadow

bin:::bin,daemon
The above: As a separate this representative (group name, group password, group Administrator, the group members!!!) Invalid representative)

UID Type Range
6 System 7 System
Super users 0 0
System Users 1-499 201-999
Normal User 500-60000 1000-60000
65535 maximum number of support (highlighted here, 65535 is the number, not the range!) That means you create a user who can assign 65536!! to him. )

(1) Useradd,groupadd + username + OPTION (create User/group)
-U (Specify UID)
-g (Specify GID or group name-default group)
-g (Specify satellite group)
-D (Specify home directory)
-S (Specify shell)
(2) ID + user (view user information)
(3) passwd + username (add a password to the user, the user initially created root to give the password to log in, the ordinary user to change the password to know the original password, but also to comply with certain rules

The
(4) Echo password |passwd--stdin user (batch to user set password, that is a bit faster, but password plaintext is not safe)
(5) Group + user name (user belongs to those groups)
(6) Usermod + options + parameters (6 system can only do so, 7 system does not matter, modify existing users)
-U (Modify UID)
-G (default set of revisions)
-g (Specify subordinate group, multiple use, delimited)
-D (Modify home directory)
-S (Modify shell)
-ag (add a subordinate group, do not overwrite the original)
(7) Groupmod-g GID group name (GID of modified Group)
(8) groupadd-n new group name old group name (modify group name)
(9) GPASSWD Group name (Modify group password)
(Ten) userdel-r User (delete user, if not add-r, mail, group also exists)
(one) Groupdel Group name (delete Group, if the group has users in the bread, then can not be deleted, you have to remove the user or delete the line)
(chage) + User (Wizard mode to modify user password policy)
(+) Chsh + user (Modify user shell)

User Switching
Su-+ user (standard switching is the environment variable of the user being switched)
Su + user (this should theoretically be a variable for the current user, but I am switching the user variable that can be used in the past)
su-l+ user (as with Su-)
Su-m + user (use current variable, here is correct)
su-c Command + user (after instruction)
(The current user variable can be viewed with env, all variables with set view) (except ROOT,SU to any user need password: So not xxx full)

sudo (safe and easy to manage compared to SU)
With sudo, a normal user can perform some root executable without switching to root, and how much can be done to see how root is written in his control file, and then

Go down and see

[Email protected] ~]# Visudo

## Allow root to run any commands anywhereroot    ALL=(ALL)       ALL

The above is introduced from root (where the user executes what command in whose identity--the command must be an absolute path---absolute path can be viewed with the which+ command. Life

Let's get ahead! Representative does not execute)

Here I add this one

root    ALL=(ALL)       ALLtom     ALL=(root)      /usr/sbin/useradd

[Email protected] ~]# su-m Tom
BASH:/root/.bashrc:permission denied
bash-4.1$ sudo useradd haha

We Trust you are received the usual lecture from the local System
Administrator. It usually boils down to these three things:

#1) Respect the privacy of others.#2) Think before you type.#3) With great power comes great responsibility.

[sudo] password for Tom:
bash-4.1$ if haha

^c
bash-4.1$ ID haha
uid=503 (haha) gid=503 (haha) groups=503 (haha)
Sudo-u user + command (typically used when root gives you other people's identity)
Sudo-k (Clear password cache)

Linux basic Commands (ii)

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.