Linux常用命令
shutdown |
shutdown [选项] [时间] [警告信息] |
shutdown -k 准备关机 |
|
shutdown -r 5 |
|
shutdown -h now |
|
shutdown -c |
|
shutdown -r now “我要重启了” |
|
halt |
调用“shutdown -h now”命令执行关机 |
reboot |
相当于“shutdown -r now” |
help |
[命令] --help |
ls --help 调取出ls命令的帮助信息 |
|
History |
查看命令历史 |
history 30 |
|
pwd |
显示当前所处工作目录的绝对路径 |
cd |
cd 路径 |
cd .. |
|
cd . |
|
cd - |
|
cd ~ |
|
cd /home |
|
ls |
列出当前目录文件夹和文件的信息 |
ls -a /home |
|
ls -l |
|
touch |
touch file |
touch -t 1705031111 file |
|
touch -c file |
|
mkdir |
mkdir test |
mkdir -p /home/test01/test02 |
|
rmdir |
rmdir test |
cp |
cp a b |
cp -a a/ b/ |
|
cp -f a b/ |
|
cp -r a/ b/ |
|
mv |
mv a b |
mv -f a /b |
|
rm |
rm -r test |
rm -f test |
|
wc |
wc file |
wc -c file |
|
wc -c file |
|
wc -l file |
|
wc -w file |
|
cat |
cat file |
cat -n file |
|
cat -b file |
|
cat -s file |
|
more |
more file |
more -20 file |
|
more +20 file |
|
head |
head file |
head -5 file |
|
tail |
tail file |
tail -5 file |
|
grep |
grep ‘test’ file |
grep -i ‘test’ file |
|
find |
find / -name test |
find / -cmin -5 |
|
find / -ctime -3 |
|
file filename |
|
hostname |
显示主机名称 |
cal |
显示日历 |
date |
显示当前系统时间 |
date +%Y-%m-%d' '%H:%M:%S |
|
date -s "2017-05-02 12:12:12" |
|
echo |
echo 我是一段文字 |
clear |
清除屏幕上的信息 |
uptime |
显示现在时间,系统运行时长,当前登录用户数,系统在过去的1分钟、5分钟、15分钟内CPU的负载情况 |
ps |
显示进程信息 |
ps -ef|grep test |
|
kill |
杀死进程 |
kill -9 233 |
|
chmod |
chmod u+w file |
chmod g-r file |
|
chmod o=x file |
|
chmod +wr file |
|
u:所有者 |
|
"+":添加某权限 |
|
r:可读 |
|
chmod 006 file |
|
第一个数字代表所有者,第二个数字代表用户组,第三个数字代表其他用户 |
|
r:代表数值为4 |
|
chown |
chown Once file |
chown -R Once test/ |
|
chgrp |
chgrp Once file |
chgrp -R Once test/ 递归修改test文件夹以及文件夹里面的文件用户组为Once |
|
/etc |
/etc/passwd |
/etc/shadow |
|
useradd |
useradd newuser |
useradd -g Once newuser |
|
useradd -G Once newuser |
|
useradd -d /home/new newuser |
|
useradd -u 666 newuser |
|
passwd |
passwd newuser |
usermod |
usermod -g Once olduser |
usermod -G Once olduser |
|
usermod -l newname oldname |
|
usermod -u 888 olduser |
|
userdel |
userdel -r olduser 删除用户olduser并删除对应的宿主目录,不加-r参数则不删除对应目录 |
groupadd |
groupadd newgroup |
groupadd -g 666 newgroup |
|
groupmod |
groupmod -g 888 oldgroup |
groupmod -n newname oldname |
|
groupdel |
groupdel oldgroup |
gpasswd |
gpasswd -a Once oldgroup |
gpasswd -d Once oldgroup |
|
gpasswd Once |
|
gpasswd -r Once |
|
groups |
groups Once |
passwd |
passwd -d Once |
passwd -l Once |
|
passwd -u Once |
|
passwd -S Once |
|
chage |
chage -m 0 Once |
chage -M 99999 Once |
|
chage -d 2017-05-03 Once |
|
chage -I 0 Once |
|
chage -I(大写i) 1 Once |
|
chage -E 2019-01-01 Once |
|
chage -W 7 Once |
|
chage -l(小写L) Once |
|
chage Once |
|
/ect目录 |
/etc/passwd |
/etc/shadow |
|
/etc/group |
|
/etc/gshadow |
|
/etc/skel |
|
/etc/login.defs |