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

-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
-
Pinduoduo's "Trillion-Yuan Support" Plan: A Three-Year, 100 Billion Yuan Investment to Build a Multi-Win Business EcosystemDetail
2025-04-03 14:41:29 11
-
Huyu Xianxiang and AVIC Optoelectronics Institute Forge Strategic Partnership to Shape China's eVTOL Avionics LandscapeDetail
2025-04-02 18:39:02 1
-
Haier Smart Home's 8th Global R&D Innovation Awards: Illuminating Better Lives with Technology, Achieving User SatisfactionDetail
2025-04-02 15:57:33 21
-
Huawei's 2025 China Digital Power Partner Conference: Carbon-Neutral Path for China, Shared Value CreationDetail
2025-03-31 18:57:09 11
-
OPPO Think Tank: A New Paradigm for Chinese Enterprises' Globalization From Wusha Village to the Global High-End MarketDetail
2025-03-31 18:48:21 1
-
ICLR 2025: Chinese Universities and Companies Showcase AI Prowess with Numerous Accepted Papers; Stanford-HKUST Collaboration Achieves Perfect ScoreDetail
2025-03-31 14:54:45 11
-
Huawei HarmonyOS Smart Home Partner Summit: Deep Dive into Spatial Intelligence Transformation and Ecosystem Development StrategyDetail
2025-03-31 13:01:45 1
-
AI Large Models Drive Innovation in Humanoid Robots and Autonomous Driving: 2025 as a Key MilestoneDetail
2025-03-31 13:00:04 1
-
Eight Cities Pilot Credit Supervision Data Openness, Empowering Micro and Small Enterprises with Mobile Payment PlatformsDetail
2025-03-26 09:32:47 1
-
Xiaomi's "Just a Little Profit": The Deep Logic and Sustainability Behind its Low-Margin StrategyDetail
2025-03-25 15:07:32 21
- Detail
-
The Ninth Huawei ICT Competition China Challenge Finals Conclude Successfully: Kunpeng and Ascend Tracks Crown Their ChampionsDetail
2025-03-24 16:26:03 11
-
Ronshen Sugar Cube Refrigerator: The Official Product of the 2025 FIFA Club World Cup, Ushering in a New Era of Healthy Food PreservationDetail
2025-03-24 15:40:35 21
-
Zhihu Launches New Version of Zhihu Straight Answer: Deep Integration of AI and Community to Enhance Professionalism and CredibilityDetail
2025-03-24 14:04:38 1
-
China Construction Ninth Harmony (Zhongjian Jiuhe) and Huawei HarmonyOS Smart Home Deepen Strategic Partnership at AWE2025, Building a Green and Intelligent Future HomeDetail
2025-03-23 15:21:15 41
-
ZuoYeBang Books Leads the New Trend in Intelligent Education Publishing at Changsha Book FairDetail
2025-03-21 15:15:33 1
-
Tianyancha: Shielding Consumer Safety and Reshaping Business Trust with DataDetail
2025-03-21 08:47:58 1
-
Hisense at AWE2025: AI Empowerment, Leading the Transformation of Future Smart LivingDetail
2025-03-20 18:24:11 11
-
Haier TV Makes a Stunning Debut at AWE 2024: Zhiyuan AI Large Model and PureScene Care Screen Usher in a New Era of Smart HomesDetail
2025-03-20 15:17:20 1
-
China Power's Xin Yuan Zhi Chu (New Source Smart Storage): Open Energy Intelligence Computing Center Leads Intelligent Transformation of the Energy IndustryDetail
2025-03-20 15:15:39 1