init 0 关机
showdown -h now 关机
init 6 重启
[root@localhost ~]# who
root pts/0 2019-12-09 01:58 (192.168.209.1)
[root@localhost ~]# tty
/dev/pts/0
[root@localhost ~]#
root@localhost ~]# whoami
root
[root@localhost ~]# date
Mon Dec 9 02:54:48 EST 2019
[root@localhost ~]# date 110815492018
Thu Nov 8 15:49:00 EST 2018
[root@localhost ~]# cal
November 2018
Su Mo Tu We Th Fr Sa
1 2 3
4 5 6 7 8 9 10
11 12 13 14 15 16 17
18 19 20 21 22 23 24
25 26 27 28 29 30
root@localhost ~]# cal 10 5 1997
May 1997
Su Mo Tu We Th Fr Sa
1 2 3
4 5 6 7 8 9 10
11 12 13 14 15 16 17
18 19 20 21 22 23 24
25 26 27 28 29 30 31
root@localhost ~]# clear
或者ctel+l
[root@localhost ~]# passwd
Changing password for user root.
New password:
BAD PASSWORD: The password is shorter than 8 characters
Retype new password:
passwd: all authentication tokens updated successfully.
[root@localhost ~]# echo 123 | passwd --stdin root
Changing password for user root.
passwd: all authentication tokens updated successfully.
[root@localhost ~]#
root@localhost ~]# man passwd
PASSWD(1) User utilities PASSWD(1)
NAME
passwd - update user's authentication tokens
SYNOPSIS
passwd [-k] [-l] [-u [-f]] [-d] [-e] [-n mindays] [-x maxdays] [-w warndays] [-i
inactivedays] [-S] [--stdin] [username]
DESCRIPTION
The passwd utility is used to update user's authentication token(s).
This task is achieved through calls to the Linux-PAM and Libuser API. Essentially,
it initializes itself as a "passwd" service with Linux-PAM and utilizes configured
password modules to authenticate and then update a user's password.
A simple entry in the global Linux-PAM configuration file for this service would be:
#
# passwd service entry that does strength checking of
# a proposed password before updating it.
#
passwd password requisite pam_cracklib.so retry=3
passwd password required pam_unix.so use_authtok
#
Note, other module types are not required for this application to function cor‐
rectly.
OPTIONS
-k, --keep
The option -k is used to indicate that the update should only be for expired
authentication tokens (passwords); the user wishes to keep their non-expired
tokens as before.
[root@localhost ~]# passwd --help
Usage: passwd [OPTION...] <accountName>
-k, --keep-tokens keep non-expired authentication tokens
-d, --delete delete the password for the named account (root only)
-l, --lock lock the password for the named account (root only)
-u, --unlock unlock the password for the named account (root only)
-e, --expire expire the password for the named account (root only)
-f, --force force operation
-x, --maximum=DAYS maximum password lifetime (root only)
-n, --minimum=DAYS minimum password lifetime (root only)
-w, --warning=DAYS number of days warning users receives before password expiration
(root only)
-i, --inactive=DAYS number of days after password expiration when an account becomes
disabled (root only)
-S, --status report password status on the named account (root only)
--stdin read new tokens from stdin (root only)
Help options:
-?, --help Show this help message
--usage Display brief usage message
延伸:help后+管道符+less
告诉less把ls --help的命令结果变成分样的方式去查看
[root@localhost ~]# ls --help |less
Usage: ls [OPTION]... [FILE]...
List information about the FILEs (the current directory by default).
Sort entries alphabetically if none of -cftuvSUX nor --sort is specified.
Mandatory arguments to long options are mandatory for short options too.
-a, --all do not ignore entries starting with .
-A, --almost-all do not list implied . and ..
--author with -l, print the author of each file
-b, --escape print C-style escapes for nongraphic characters
--block-size=SIZE scale sizes by SIZE before printing them; e.g.,
'--block-size=M' prints sizes in units of
1,048,576 bytes; see SIZE format below
-B, --ignore-backups do not list implied entries ending with ~
-c with -lt: sort by, and show, ctime (time of last
modification of file status information);
with -l: show ctime and sort by name;
otherwise: sort by ctime, newest first
-C list entries by columns
--color[=WHEN] colorize the output; WHEN can be 'never', 'auto',
or 'always' (the default); more info below
-d, --directory list directories themselves, not their contents
-D, --dired generate output designed for Emacs' dired mode
-f do not sort, enable -aU, disable -ls --color
-F, --classify append indicator (one of */=>@|) to entries
--file-type likewise, except do not append '*'
--format=WORD across -x, commas -m, horizontal -x, long -l,
single-column -1, verbose -l, vertical -C
--full-time like -l --time-style=full-iso
-g like -l, but do not list owner
--group-directories-first
group directories before files;
can be augmented with a --sort option, but any
use of --sort=none (-U) disables grouping
-G, --no-group in a long listing, don't print group names
:
命令本身+选项+参数
[root@localhost ~]# passwd -S root
root PS 2018-11-07 0 99999 7 -1 (Password set, SHA512 crypt.)
[root@localhost /]# ls /
bin dev home lib64 mnt proc run srv tmp var
boot etc lib media opt root sbin sys usr
[root@localhost ~]# pwd
/root
boot目录存放的一些东西,类似于启动盘
root@localhost /]# cd /boot/
You have mail in /var/spool/mail/root
[root@localhost boot]# ls
config-3.10.0-693.el7.x86_64
efi
grub
grub2
initramfs-0-rescue-7ec60be873584f3ca3222e7e066817c5.img
initramfs-3.10.0-693.el7.x86_64.img
initrd-plymouth.img
symvers-3.10.0-693.el7.x86_64.gz
System.map-3.10.0-693.el7.x86_64
vmlinuz-0-rescue-7ec60be873584f3ca3222e7e066817c5
vmlinuz-3.10.0-693.el7.x86_64
[root@localhost boot]#
bin目录存放的是常用的命令
[root@localhost boot]# cd
[root@localhost ~]# cd /bin/
[root@localhost bin]# ls
[ iptables-xml readlink
addr2line isosize realpath
alias jobs recode-sr-latin
apropos join rename
ar journalctl renice
arch kbdinfo reset
as kbd_mode resizecons
aserver kbdrate rev
aulast kdumpctl rm
sbin目录存放的是系统命令
[root@localhost ~]# ls /sbin
accessdb grub2-get-kernel-settings postkick
addgnupghome grub2-install postlock
addpart grub2-mkconfig postlog
adduser grub2-ofpathname postmap
agetty grub2-probe postmulti
alternatives grub2-reboot postqueue
anacron grub2-rpm-sort postsuper
applygnupgdefaults grub2-set-default poweroff
arpd grub2-setpassword ppp-watch
etc目录存放的是配置文件
[root@localhost bin]# cd /etc/
[root@localhost etc]# ls
adjtime GeoIP.conf modules-load.d rwtab
aliases GeoIP.conf.default motd rwtab.d
aliases.db gnupg mtab sasl2
alternatives GREP_COLORS my.cnf securetty
anacrontab groff my.cnf.d security
asound.conf group NetworkManager selinux
audisp group- networks services
audit grub2.cfg nsswitch.conf sestatus.conf
bash_completion.d grub.d nsswitch.conf.bak shadow
bashrc gshadow openldap shadow-
mnt目录是挂载目录
[root@localhost ~]# ls /mnt
[root@localhost ~]#
[root@localhost ~]# ls /boot/grub/splash.xpm.gz
/boot/grub/splash.xpm.gz
[root@localhost ~]# cd /boot/
[root@localhost boot]# ls grub/splash.xpm.gz
grub/splash.xpm.gz
[root@localhost ~]# mkdir /a
[root@localhost ~]# mkdir /a/d
[root@localhost ~]# mkdir /a/e
[root@localhost ~]# mkdir /a/f
[root@localhost ~]# ls /a
d e f
递归建目录 -p
[root@localhost ~]# mkdir -p /b/g
[root@localhost ~]# ls /b
g
-d代表查看目录结构而不是目录的内容
[root@localhost ~]# ls -d /a/e
/a/e
[root@localhost ~]#
重命名
[root@localhost ~]# ls /a
d e f
[root@localhost ~]# mv /a/f /a/f1
[root@localhost ~]# ls /a
d e f1
移动目录
[root@localhost ~]# ls /a
d e f1
[root@localhost ~]# ls /b
g g,h,j h t y
[root@localhost ~]# mv /a/f1 /b
[root@localhost ~]# ls /b
f1 g g,h,j h t y
如果目录下有多个子目录可以用rm -r,但是还是要递归确定删除。
[root@localhost ~]# rm -r /b
rm: descend into directory ‘/b’? y
rm: remove directory ‘/b/g’? y
rm: remove directory ‘/b/g,h,j’? y
rm: descend into directory ‘/b/h’? y
rm: remove directory ‘/b/h/b’? ^C
[root@localhost ~]# ls /b
f1 h t y
不需要提示,直接全部删除rm -r -f 可以写一起rm -rf,一旦删除就无法恢复。
[root@localhost ~]# rm -rf /b
[root@localhost ~]# ls /
a boot dev home lib64 mnt proc run srv tmp var
bin d etc lib media opt root sbin sys usr
我们可以用mv命令代替删除,将想删除的目录移动到/tmp下,这里相当于回收站。想恢复的话就用mv命令移动回来。
[root@localhost ~]# mv /a /tmp
[root@localhost ~]# ls/tmp
-bash: ls/tmp: No such file or directory
[root@localhost ~]# ls /tmp
a
ks-script-LYyMNT
systemd-private-0c9d2a41d4b74ab38268e43c4db6a922-chronyd.service-Tf8wRr
systemd-private-42483447ed7541d988884261074ceee9-chronyd.service-RwUmSC
systemd-private-495d923bfde54bde85e7f8cb31ffeeb9-chronyd.service-OKksLw
systemd-private-b257d2d6865849aa9671e346ee2a8966-chronyd.service-P0VvcH
systemd-private-bb99b72d1da6407da31f4078908ac69e-chronyd.service-owVTTH
systemd-private-be5c91c4d3f2465cb0ad8f9350a51a4d-chronyd.service-TjpoQS
systemd-private-d9c4ac62008e4c55b9f52d3d8a4b0202-chronyd.service-rj7TG6
yum.log
[root@localhost ~]# touch /a.txt
[root@localhost ~]# ls /
a.txt boot etc lib media opt root sbin sys usr
bin dev home lib64 mnt proc run srv tmp var
注意:这里我都操作是在root不是在/,所以我使用命令时加的有/的绝对路径。
[root@localhost ~]# mv /a.txt /b.txt
[root@localhost ~]# ls
anaconda-ks.cfg
[root@localhost ~]# ls /
bin b.txt etc lib media opt root sbin sys usr
boot dev home lib64 mnt proc run srv tmp var
在/下就就可以用相对路径的操作是这样的。
[root@localhost ~]# cd /
[root@localhost /]# mv b.txt c.txt
[root@localhost /]# ls
bin c.txt etc lib media opt root sbin sys usr
boot dev home lib64 mnt proc run srv tmp var
[root@localhost /]# ls c.txt
c.txt
[root@localhost /]# rm c.txt
rm: remove regular empty file ‘c.txt’? y
[root@localhost /]# ls
bin dev home lib64 mnt proc run srv tmp var
boot etc lib media opt root sbin sys usr
[root@localhost /]# touch a.txt
[root@localhost /]# ls
a.txt boot etc lib media opt root sbin sys usr
bin dev home lib64 mnt proc run srv tmp var
[root@localhost /]# rm -f a.txt
[root@localhost /]# ls
bin dev home lib64 mnt proc run srv tmp var
boot etc lib media opt root sbin sys usr
原文:https://www.cnblogs.com/wang977/p/12022722.html