Chapter 03- Linux Common Commands
AD |
02-vmwarecentos7shellshell(kernel)shell-2-1-2-1shellshellshellshellshellBourne Shell/usr/bin/sh/bin/shBourne Again Shell/bin/bashC Shell/usr/bin/cshK Shell/usr/bin/kshshell[root@cdphost ~]# echo $SHELL/bin/bashLinuxman[root@cdphost ~]# man lsreboot[root@cdphost ~]# rebootshutdown[root@cdphost ~]# shutdownlsls [] []ls-l-a-A.
02-vmwarecentos7
shellshell(kernel)shell-2-1
shellshellshellshell
shellBourne Shell/usr/bin/sh/bin/shBourne Again Shell/bin/bashC Shell/usr/bin/cshK Shell/usr/bin/ksh
- shell
[root@cdphost ~]# echo $SHELL/bin/bash
man
[root@cdphost ~]# man ls
reboot
[root@cdphost ~]# reboot
shutdown
[root@cdphost ~]# shutdown
ls
ls [] []
ls
-l | |
-a | |
-A | ... |
-h | |
-t | |
-r |
[root@cdphost ~]# ls -ltotal 4194316-rw-------. 1 root root 1808 Dec 15 2022 anaconda-ks.cfg-rw------- 1 root root 1908 Jun 19 16:56 dead.letterdrwxr-xr-x. 2 root root 6 Dec 15 2022 Desktopdrwxr-xr-x. 2 root root 6 Dec 15 2022 Documents... ...
pwd
[root@cdphost ~]# pwd/root
cd
cd <>
. | |
.. | |
~ | Home |
- | |
/home/cdp |
[root@cdphost ~]# cd /usr/bin[root@cdphost bin]# pwd/usr/bin
mkdir
mkdir [] <>
mkdir
-p |
[root@cdphost ~]# mkdir -p /root/temp1/temp2[root@cdphost ~]# cd /root/temp1/temp2/[root@cdphost temp2]# pwd/root/temp1/temp2
rm
rm [] </>
rm
-r | |
-f |
[root@cdphost temp2]# pwd/root/temp1/temp2[root@cdphost temp2]# cd ~[root@cdphost ~]# pwd/root[root@cdphost ~]# rm -rf temp1[root@cdphost ~]#
rename
rename
[root@cdphost temp1]# lsaaa aaabbb.txt dddaaa.txt[root@cdphost temp1]# rename aaa bbb aaabbb.txt[root@cdphost temp1]# lsaaa bbbbbb.txt dddaaa.txt[root@cdphost temp1]#
mv
mv <> <>
1/root/temp1/aaa/root/temp2
[root@cdphost temp1]# mv /root/temp1/aaa /root/temp2
2/root/temp1/aaa/root/temp2
[root@cdphost temp1]# mv /root/temp1/aaa/* /root/temp2/bbb
3/root/temp2bbbccc
[root@cdphost temp2]# mv /root/temp2/bbb /root/temp2/ccc
cp
cp <> <>
cp
-r |
1/root/temp1/aaa/root/temp2/ccc
[root@cdphost ccc]# cp -r /root/temp1/aaa /root/temp2/ccc
2/root/temp1/aaa/root/temp2/ccc
[root@cdphost ccc]# cp -r /root/temp1/aaa/* /root/temp2/ccc
touch
[root@cdphost temp1]# lltotal 0[root@cdphost temp1]# touch a.txt[root@cdphost temp1]# lltotal 0-rw-r--r-- 1 root root 0 Jun 25 23:00 a.txt
cat
[root@cdphost temp1]# cat /etc/passwd
more
[root@cdphost temp1]# more /etc/passwd
head
10
head []
head
-n |
1/etc/group5
[root@cdphost temp1]# head -n 5 /etc/grouproot:x:0:bin:x:1:daemon:x:2:sys:x:3:adm:x:4:
tail
10
tail []
tail
-n | |
-f |
1/etc/group5
[root@cdphost temp1]# tail -n 5 /etc/grouptcpdump:x:72:stapusr:x:156:stapsys:x:157:stapdev:x:158:cdp:x:1000:cdp
2/root/cdp.txt
[root@cdphost ~]# tail -f cdp.txt788
wc
wc []
wc
-l | |
-w | |
-c |
1/etc/passwd
[root@cdphost ~]# wc -l /etc/passwd43 /etc/passwd
2/etc/passwd
[root@cdphost ~]# wc -w /etc/passwd87 /etc/passwd
3/etc/passwd
[root@cdphost ~]# wc -c /etc/passwd2256 /etc/passwd
du
dd
du
-h | |
-s | |
-b | byte |
-m | M |
-k | K |
1
[root@cdphost temp1]# du -sh3.5G .
2
[root@cdphost temp1]# du -sh *100K 100K_temp.txt100M 100M_temp.txt1.0G 1G_temp.txt4.0K 2048_temp.txt2.4G a
3
[root@cdphost temp1]# du -sh /root/temp1/a2.4G /root/temp1/a
4
[root@cdphost temp1]# du -sh /root/temp1/a | cut -f12.4G[root@cdphost temp1]# du -sh /root/temp1/a | awk '{print $1}'2.4G
find
find path -option [-print ] [ -exec -ok command ] {} ;
find
-name | |
-type | f |
-size |
1.c
[root@cdphost temp1]# find / -name "*.c"/usr/lib/firmware/isci/create_fw.c/usr/lib64/perl5/vendor_perl/auto/share/dist/DBD-SQLite/sqlite3.c/usr/share/doc/libpng-1.5.13/example.c/usr/share/doc/mpfr-3.1.1/mpfr/examples/divworst.c/usr/share/doc/mpfr-3.1.1/mpfr/examples/rndo-add.c/usr/share/doc/mpfr-3.1.1/mpfr/examples/sample.c/usr/share/doc/mpfr-3.1.1/mpfr/examples/version.c/usr/share/doc/libbluray-0.2.3/player_wrappers/xine/input_bluray.c
2100M
[root@cdphost temp1]# find /root/temp1 -size +100M -exec ls -lh {} ;-rw-r--r--. 1 root root 1.0G Dec 23 12:34 /root/temp1/1G_temp.txt-rw-r--r--. 1 root root 2.0G Dec 23 12:51 /root/temp1/a/temp.txt-rw-r--r--. 1 root root 400M Dec 23 12:53 /root/temp1/a/b/100M_temp.txt
grep
grep [] [] file
grep
-v | |
-n | |
-c | |
-r |
1hello
[root@cdphost temp1]# grep "hello" /root/temp1 -rn/root/temp1/b.txt:3:asdfsaf hello/root/temp1/c/c.txt:10:hello hello/root/temp1/a.txt:6:abc hello/root/temp1/a.txt:7:hello cdb
2hello
[root@cdphost temp1]# grep "hello" /root/temp1 -rc | grep ":0" -v/root/temp1/b.txt:1/root/temp1/c/c.txt:1/root/temp1/a.txt:2
3hello
[root@cdphost temp1]# grep "hello" /root/temp1 -rc | grep ":0" -v | cut -d ":" -f1/root/temp1/b.txt/root/temp1/c/c.txt/root/temp1/a.txt
4
[root@cdphost temp1]# grep "^$" /root/temp1/a.txt -n3:5:
linux$cat -A /root/temp1/a.txt
5java
[root@cdphost temp1]# ps -ef | grep java | grep -v grep
date
date [] [+]
date
-s datestr | datestr |
date
%Y | (0000..9999) |
%m | (01..12) |
%d | (01..31) |
%H | (00..23) |
%M | (00..59) |
%S | (00..59) |
%A | (Sunday..Saturday) |
%j |
1[yyyy-mm-dd hh:mm:ss]
[root@cdphost temp1]# date '+%Y-%m-%d %H:%M:%S'2022-12-23 15:48:40
2
[root@cdphost temp1]# date '+%A'Friday
320211231 9:00:00
[root@cdphost temp1]# date -s '2021-12-31 9:00:00'
ifconfig
IP
[root@cdphost temp1]# ifconfig
df
df []
df
-T | |
-h |
1
Filesystem
Size
Used
Avail
Use%
Mounted on
free
free []
free
-h | |
-m | M |
1
total
used
free
shared
buff/cache
available
top
[root@cdphost temp1]# top
top - 22:42:52 up 42 min, 2 users, load average: 0.13, 0.09, 0.12
22:42:5242 21,5,150.13, 0.09, 0.12
load average()CPU,(1,5,15)
Tasks: 492 total, 1 running, 491 sleeping, 0 stopped, 0 zombie
4921()491()0(stoppedkill)0()
%cpu(s): 7.2 us, 1.4 sy, 0.0 ni, 91.3 id, 0.0 wa, 0.0 hi, 0.2 si, 0.0 st
7.2% us CPU
1.4% sy CPU
0.0% ni CPU
91.3 % id CPU
0.0% wa IOCPU
0.0% hi Hardware IRQCPU
0.2% si Software InterruptsCPU
0.0% st CPU
CPUwindows
KiB Mem: 2035648 total, 888272 used, 1147376 free, 884 buffers
2035648k total 2035M
888272k used 888M
1147376k free 1147M
884k buffers 0.8M
KiB Swap: 2097148 total, 0 used, 2097148 free. 255104 cached Mem
swap
2097148k total 2097M
0k used 0M
2097148 k free 2097M
255104k cached 255M
used
PID | ID |
USER | |
PR | 'rt' |
NI | nice |
VIRT | kbVIRT=SWAP+RES |
RES | kbRES=CODE+DATA |
SHR | SHRkb |
S | ,: D - R S T Z |
%CPU | CPU |
%MEM | |
TIME+ | CPU |
COMMAND | / |
who
NAME
LINEpts/0:0x(x-window)
TIME
COMMENTIP
whoami
[root@cdphost ~]# whoamiroot
ps
ps []
ps
-e | () |
-f |
15
2java
[root@cdphost ~]# ps -ef | grep java | grep -v grep
kill
1
[root@cdphost ~]# kill -9
2
[root@cdphost ~]# kill -9 1 2 3
which
1pwd
[root@cdphost ~]# which pwd/usr/bin/pwd
wget
1centos7163yum
[root@cdphost temp1]# wget http://mirrors.163.com/.help/CentOS7-Base-163.repo
su
su [-]
su --
su - --
1su PATH
2su - PATH
sudo
sudo
sudo
1visudo
2/etc/sudoers(chmod u+w /etc/sudoers)
(/etc/sudoers)
visudo | |
cdp ALL=(ALL) ALL | cdpsudo |
%cdp ALL=(ALL) ALL | cdpsudo |
cdp ALL=(ALL) NOPASSWD:ALL() | cdpsudo |
%cdp ALL=(ALL) NOPASSWD:ALL | cdpsudo |
ALLsudo192.168.226.250/24
ALL
ALL
1cdpsudo
1visudo/etc/sudoers
[root@cdphost ~]# visudo --/etc/sudoers
2
[cdp@cdphost ~]$ sudo systemctl stop firewalld
history
110
[root@cdphost ~]# history | tail -n 10951 echo $PATH952 systemctl status firelwalld953 systemctl status firewalld954 visudo955 cat /etc/sudoers956 vi /etc/sudoers957 ll /etc/sudoers958 visudo959 history960 history | tail -n 10
2
[root@cdphost ~]# !951echo $PATH/usr/local/sbin:/usr/local/bin:/sbin:/bin:/usr/sbin:/usr/bin:/root/bin
scp
linux
1.scp [] local_file remote_username@remote_ip:remote_file2.scp [] remote_username@remote_ip:remote_file local_file
scp
-r |
1
[root@cdphost temp1]# scp 100M_temp.txt [email protected]:/root/temp3[root@cdphost temp1]# scp -r /root/temp2 [email protected]:/root/temp3
2
[root@cdphost temp4]# scp [email protected]:/root/temp3/100M_temp.txt ./[root@cdphost temp4]# scp -r [email protected]:/root/temp3/temp2 ./
gzip
gzip [] []
gzip
-d | |
-l | |
-v |
1
2
3
tar
tar [] [] [..]
tar
-c | |
-v | |
-f | |
-x | |
-z | gzip,.gz |
-t | |
-C |
-c-x
linux3
-z | gzip | .tar.gz | gz > bz2 > xz xz > bz2 > gz |
-j | bzip2 | .tar.bz2 | |
-J | xz | .tar.xz |
1
2
3
4
5
6
zip
zip [] [.zip] [1]
zip
-q | |
-r |
1
unzip
uzip [] [.zip]
uzip
-l | |
-d |
1
Disclaimer: The content of this article is sourced from the internet. The copyright of the text, images, and other materials belongs to the original author. The platform reprints the materials for the purpose of conveying more information. The content of the article is for reference and learning only, and should not be used for commercial purposes. If it infringes on your legitimate rights and interests, please contact us promptly and we will handle it as soon as possible! We respect copyright and are committed to protecting it. Thank you for sharing.(Email:[email protected])
Mobile advertising space rental |
Tag: Chapter Linux Common Commands
During the Dragon Boat Festival of Kwai, the amount of local life orders increased by more than 45%
NextBig data helps eliminate pornography? If you meet the following characteristics, you may be "involved in pornography" without realizing it
Guess you like
- Detail
-
NetEase Cloud Music's 2024 Annual Music Report Launches: Innovative Features Like Couple's Reports and Artist Handwritten Letters Create a More Detailed Musical Journey RetrospectiveDetail
2024-12-27 12:11:38 1
-
"Macau Story," a mini-series celebrating the 25th anniversary of Macau's return to China, achieves a billion viewsDetail
2024-12-24 16:38:43 1
-
Youku Sports and VICTOR Partner to Deliver an Upgraded and Innovative Live Streaming Experience for the 2024 BWF World Tour FinalsDetail
2024-12-24 14:31:57 1
-
Foxconn's Parent Company, Hon Hai Precision Industry, Invests an Additional RMB 600 Million in its Zhengzhou-based EV Battery UnitDetail
2024-12-24 10:01:13 1
-
2024 Spring Festival Travel Rush New Train Schedule: 321 Additional Trains Nationwide Starting January 5th, Further Enhancing Service Quality and EfficiencyDetail
2024-12-23 12:05:44 1
-
Changan Automobile and EHang Intelligent Sign Strategic Cooperation Agreement to Build Future Flying Car EcosystemDetail
2024-12-22 15:08:38 1
-
Liaoning Province and Baidu Sign Strategic Cooperation Framework Agreement to Jointly Promote AI Industry DevelopmentDetail
2024-12-20 19:36:38 1
-
Wanxun Technology Secures Nearly RMB 200 Million in Funding to Lead Global Soft Robotics Innovation, Set to Showcase Breakthroughs at CES 2025Detail
2024-12-20 15:54:19 1
-
Huolala's 2025 Spring Festival Freight Festival: Supporting Spring Festival Travel, Offering New Year Benefits to Users and DriversDetail
2024-12-20 13:38:20 1
-
The Third Meeting of the Third Council of the International New Energy Solutions Platform (INES): Charting a Blueprint for a "Dual Carbon" FutureDetail
2024-12-19 17:03:07 1
-
WeChat's Official Account Launches "Author Read Aloud Voice" Feature for Personalized Article ListeningDetail
2024-12-18 17:19:57 1
-
The 12th China University Students' Polymer Materials Innovation and Entrepreneurship Competition Finals Grand Opening in Guangrao CountyDetail
2024-12-18 16:04:28 1
-
Tracing the Ancient Shu Road, Winds of the Three Kingdoms: Global Influencer Shu Road Journey LaunchesDetail
2024-12-18 15:23:35 1
-
Seres: A Pioneer in ESG Practices, Driving Sustainable Development of China's New Energy Vehicle IndustryDetail
2024-12-17 16:20:26 1
- Detail
-
My Health, My Guard: Huawei WATCH D2 Aids Precise Blood Pressure Management in the Winter Health BattleDetail
2024-12-17 09:36:15 1
-
Investigation into the Chaos of Airline Seat Selection: Paid Seat Selection, Seat Locking Mechanisms, and Consumer Rights ProtectionDetail
2024-12-15 16:45:48 1
-
Japanese Scientists Grow Human Organs in Pigs: A Balancing Act of Breakthrough and EthicsDetail
2024-12-14 19:48:50 1
-
Pang Donglai and Sam's Club: Two Paths to Transformation in China's Retail IndustryDetail
2024-12-14 17:57:03 1