Basic Linux Command

linux command format: command [-options] [parameter1] …

man and help:
command --help
man 1/2/3…/8 command (man means manual)

  1. Standard commands
  2. System calls
  3. Library functions
  4. Special devices
  5. Games and toys
  6. Miscellaneous
  7. Administrative Commands

ls: list
ls -a: all(do not ignore entries start with .)
ls -l: long listing format
ls -l -h: with human readable sizes such like K, M, G
ls -lah

, ?, [](similar with SQL)
ls 1
.txt; rm 1*.txt;
ls 1?.txt
ls 1[12345]3.txt

pwd: print working directory
touch: create a new file
mkdir: make directory
mkdir A/B/C/D/E -p
cd: change directory
cd ./A: change the directory to A in the current directory
cd …
cd …/…
cd -: to the last directory
cd ~: go home
Tab for autofilling

gedit: open and edit(rarely used)
cat: print the file
history:
!2074: run the 2074th command in history

cat: show all the content of the file
more: only show a small part of the file
ls -alh /bin |more

Ctrl+c: don’t run the command

rm B -r(r = recursion)

mv old_name, new name: rename
mv 111.txt laowang/: move 111.txt to laowang/

cp 111.txt: copy
cp -r A: copy a folder

ln -s x.txt x-softlink.txt: softlink.
ln x.txt x-hardlink.txt: hardlink

grep -n(note the line in the file) -v(without ntfs) “ntfs” xxx.txt
“^ntfs” the word starts with ntfs
“ntfs$” the word ends with ntfs

find / -name “name
find / -size +2M(-2M)(2M)(+4k-size-5M)
find / -perm 777
sudo find …: without permission

tar -cvf(c=crate, v=verbose, f=file archive) test.tar *.py: put all .py file into package test.tar
tar -xvf(x=extract) test.tar: get all the files out of test.tar
tar -zcvf(z=gzip) test.tar.gz *.py: compress
tar -zxvf test.tar.gz: extract
tar -jcvf(j=bzip2) yyy.tar.bz2 *.py: a second way to compress
zip zzz.zip *.py
unzip zzz.zip
tar -zxvf test.tar.gz -C dongge/: extract to a specified directory
unzip -d ./test myzip.zip:extract to a specified directory

which ls

cal: calculate
cal -y 2008
date
date “+%y===%m====%d”: show current time with specified format

ps
ps -aux: show all the programs running
top
htop
kill: shut a programm down
kill -9(mandatory)

reboot
shutdown -h +100/now/20:20

df: check your disk usage
ud: directory usage

ifconfig
sudo ifconfig ens33 172.16.7.139: change your IP address
ping

useradd claire -m:: add a user
cat /etc/password
su claire: switch user
sudo passwd claire: change the password
whoami: show current user
exit: exist from current user
Ctrl+Shift+t: new tab
who
userdel -r username
sudo -s: switch to superuser

groupadd group_name: add a group
groupdel group_name:
cat etc/group/
groupmod Tab
sudo usermod -aG adm username
sudo usermod -aG sudo username
chown username filename: change owner
chgrp groupname filename: change group

chmod u(owner)/g(group)/o(others)=r(read)w(write)x(excute) 2.py
chmod u=r,g=r,o=r
r---->4
w---->2
x---->1
rwx: 3-bits binary code
chmod 137 *.py

shell script;
vi test.sh
chmod u+x test.sh
./test.sh

compile c file:
gcc test.c
./a.out

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值