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
-
Huawei's HarmonyOS Native Ecosystem: Thriving and Shaping the Future of Smart LivingDetail
2025-03-03 18:25:28 1
-
Unitree Robotics Founder Wang Xingxing Releases Video Statement: Warning Against Online Misinformation, Protecting Shareholder InterestsDetail
2025-03-02 12:40:18 11
-
The Age of Smart Homes Arrives: Habitat L32 Ushers in an Upgrade to Living ExperienceDetail
2025-02-28 21:16:59 1
-
Alibaba's DAMO Academy Announces Imminent Delivery of XuanTie C930 Processor, Achieving 15/GHz in SPECint2006 BenchmarkDetail
2025-02-28 11:06:08 1
-
China's OTA Platforms: A High-Efficiency Miracle Under Low Commission RatesDetail
2025-02-28 10:38:34 21
-
China Leads in Setting International Standard for Elderly Care Robots, Ushering in a New Era for the Global Silver EconomyDetail
2025-02-28 10:37:23 1
-
Xiaomi SU7 Ultra: The World's Strongest Four-Door Production Car, 10,000 Pre-orders in Two Hours, Price Drop Ignites the Market!Detail
2025-02-28 10:29:25 1
-
Kingdee Qatar Company Established: Empowering Middle Eastern Enterprises' Digital Transformation with Digital Technology, Driving the "National Vision 2030"Detail
2025-02-28 09:56:02 1
- Detail
-
DeepSeek API Price Adjustment: Off-Peak Discounts Reduce Costs, Up to 75% OffDetail
2025-02-27 10:47:53 21
-
Lenovo's Ask Tian AI Computing Platform Receives Major Upgrade, Enabling Single-Machine Deployment of 671B-Parameter DeepSeek-R1 ModelDetail
2025-02-26 15:22:05 1
-
Largest Mesozoic Scorpion Fossil Discovered in China: Jeholialongchengi Fills Fossil GapDetail
2025-02-26 10:35:56 1
-
Haier Smart Home Leads the Globalization of Appliance Services: Unified Standards, Setting a New Benchmark for Digital ServicesDetail
2025-02-25 17:39:01 1
-
Douyin Livestreaming Shops: A New Engine Driving the Digital Transformation of the Real EconomyDetail
2025-02-25 17:38:14 21
-
Zhou Hongyi, founder of 360 Group, and Nano AI Search's New Energy Vehicle Giveaway Event Concludes Successfully, Marking a Step Forward in AI PopularizationDetail
2025-02-24 18:36:23 31
-
Leaked CAD Renderings Reveal iPhone 17 Series: Two-Tone Back and Novel Camera Designs Spark InterestDetail
2025-02-24 17:27:08 1
-
Yadea Unveils the Modern Series: High-Style Design Meets Tenfold Safety, Ushering in a New Era of Women's CommuteDetail
2025-02-24 14:34:28 1
-
IBM's mandatory return-to-office policy sparks controversy: disguised layoffs, unfair to employees?Detail
2025-02-24 14:15:41 1
-
Apple Halts iCloud Advanced Data Protection in UK: A Stand Against Government 'Backdoor' DemandsDetail
2025-02-24 14:10:40 31
-
S&P Global Sustainability Yearbook 2024: Baidu's Inclusion Highlights the Crucial Role of AI GovernanceDetail
2025-02-19 21:08:50 1