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
-
China Leads in Developing IEC 63206 International Standard, Driving Global Innovation in Industrial Process Control System RecordersDetail
2025-01-18 11:06:14 1
-
The 2024 Micro-Short Series Industry Ecological Insight Report: 647,000 Job Opportunities, Rise of Diversified Business Models, and High-Quality Content as the Future TrendDetail
2025-01-17 17:33:01 1
-
Global PC Market Shows Moderate Recovery in 2024: High AIPC Prices a Bottleneck, Huge Growth Potential in 2025Detail
2025-01-17 11:02:09 1
-
Bosch's Smart Cockpit Platform Surpasses 2 Million Units Shipped, Showcasing Strength in Intelligent Driving TechnologyDetail
2025-01-17 10:55:29 1
-
YY Guangzhou Awarded "2024 Network Information Security Support Unit" for Outstanding ContributionsDetail
2025-01-17 10:43:28 1
-
TikTok CEO Invited to Trump's Inauguration, Biden Administration May Delay BanDetail
2025-01-16 20:06:11 1
-
Douyin Denies Opening International Registration: Overseas IPs Don't Equate to Overseas Registration; Platform Actively Combats Account ImpersonationDetail
2025-01-16 14:26:12 1
-
Lei Jun, Xiaomi's founder, chairman, and CEO, has set a new goal: learning to drive a forklift!Detail
2025-01-15 10:22:30 11
-
ByteDance Scholarship 2024: Fifteen Outstanding Doctoral Students Awarded RMB 100,000 Each to Advance Frontier Technology ExplorationDetail
2025-01-14 15:56:39 1
-
Fliggy Launches "Peace of Mind for the New Year" Service Initiative to Ensure Smooth Travel During the Year of the Snake Spring Festival RushDetail
2025-01-14 15:24:53 1
-
Arm's Massive Fee Hike and Potential In-House Chip Development: A Precursor to a Seismic Shift in the Chip Industry?Detail
2025-01-14 11:02:36 1
-
Adobe Firefly Launches: Generative AI Suite Revolutionizes Image and Video Processing EfficiencyDetail
2025-01-14 10:46:39 1
-
Chinese New Year Elements Sell Like Hotcakes Overseas: Cross-border E-commerce "Spring Festival Economy" Booms, Cainiao Overseas Warehouses Help Merchants Capture Market ShareDetail
2025-01-13 14:17:50 1
-
China Railway's 12306 System Successfully Navigates Spring Festival Travel RushDetail
2025-01-13 12:56:54 1
-
Handan, Hebei Province Successfully Tests First Low-Altitude Drone Delivery Route, Ushering in a New Era of Smart LogisticsDetail
2025-01-13 12:50:13 1
-
Kuaishou Leads in Developing Anti-Fraud Industry Standards, Contributing to a Secure and Reliable Short-Video CommunityDetail
2025-01-13 09:47:32 11
-
Microsoft Offers Top Salaries to Retain AI Talent: AI Software Engineers Earn Over $400,000 AnnuallyDetail
2025-01-12 17:28:34 11
- Detail
-
Chang'e-5 Mission Unveils Secrets: New Discoveries Regarding Lunar Magnetic Field Strength and Deep Dynamics 2 Billion Years AgoDetail
2025-01-10 11:42:44 11
-
SenseTime's "Day Day New" Multimodal Large Model: Native Fusion Enables Diverse ApplicationsDetail
2025-01-10 11:40:40 21