linux command format: command [-options] [parameter1] …
man and help:
command --help
man 1/2/3…/8 command (man means manual)
- Standard commands
- System calls
- Library functions
- Special devices
- Games and toys
- Miscellaneous
- 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