赞
踩
I learned this on the Youtube
https://www.youtube.com/watch?v=5UpIXY-g5Lk&list=PLT98CRl2KxKHaKA9-4_I38sLzK134p4GJ&index=8
https://www.youtube.com/watch?v=dBDmIhSWfnM&list=PLIQIswOrUH6992C4FDDCNCIaK4R2FIOCB
1 cd
change directory
cd ..
to the last dir
cd ~/
back to the home dir
2 ls ls -l
show the list of directory or ... in the current folder
3 pwd
current dir
4 man --help
menu for the cmd, ask for help, and enter 'q' for quit
cmd --help
5 touch
create a file
touch [option] file_name(s)
6 nano
^ MEANS ctrl
to create and write or edit the txt file
more guide info. here:
https://www.howtogeek.com/howto/42980/the-beginners-guide-to-nano-the-linux-command-line-text-editor/
cmd 'nano test\ file'
the name
7 mkdir rm mv cp
to remove a non-empty dir, should use ' rm -r '
to copy a non-empty dir, should use 'cp -r'
8 root sudo
9 cat
(1) show the content of the file
jieyin-HP-Pavilion-14-Notebook-PC:~/Documents> nano animals
jieyin-HP-Pavilion-14-Notebook-PC:~/Documents> nano people
jieyin-HP-Pavilion-14-Notebook-PC:~/Documents> ls
animals people
jieyin-HP-Pavilion-14-Notebook-PC:~/Documents> cat animals
panda
turtlle
cat
dog
deer
jieyin-HP-Pavilion-14-Notebook-PC:~/Documents> cat people
Dawn
Charlotte
Lily
Miao
Brandon
jieyin-HP-Pavilion-14-Notebook-PC:~/Documents> cat animals people
panda
turtlle
cat
dog
deer
Dawn
Charlotte
Lily
Miao
Brandon
(2) to combine 2 file
jieyin-HP-Pavilion-14-Notebook-PC:~/Documents> cat animals people >newf
jieyin-HP-Pavilion-14-Notebook-PC:~/Documents> ls
animals newf people
jieyin-HP-Pavilion-14-Notebook-PC:~/Documents> cat newf
panda
turtlle
cat
dog
deer
Dawn
Charlotte
Lily
Miao
Brandon
(3) cmd > is to overwrite, is as the cmd -w in matlab fprintf
(4) cmd >> , as the cmd -a in matlab frprintf
jieyin-HP-Pavilion-14-Notebook-PC:~/Documents> cat people >> newf
jieyin-HP-Pavilion-14-Notebook-PC:~/Documents> cat newf
panda
turtlle
cat
dog
deer
Dawn
Charlotte
Lily
Miao
Brandon
Dawn
Charlotte
Lily
Miao
Brandon
10 top
to monitor the process in cpu
press cmd s, is to change the second of refreshing
press cmd i, is to only show the current process
press cmd k, an enter the pid of the running program, then, close the program (means kill signal)
press cmd f, choose which to show on the command window
11 killing program
(1) top k
(2) kill
fist to know the pid of the program, enter cmd 'pidof' and the full name of the program
and then it will show you the pid code of the running proc
and then enter 'kill' and the code
(3) kill -KILL
also, could only enter 'kill -KILL' and the code
(4) ps -ux
to find the name of process that you proc before
(5) ps -aux
to see the runniing programe under the usr
(6) ps -U usrname
to show some usrs' proc
and also to read the pid of each process
(7) ps -c processname
to kill the programe, and see the details of the specific the process
12 usr
(1) create usr
sudo useradd usrname -m -s /bin/bash -g users -G groupname
-m create the home dir for the usr
-s /bin/bash default bash to login in to
-g small group
-G groupname to input the usr into some groups
enter cmd 'ls /home', could see the new dir for the new usr
(2) set the password
sudo passwd usrname
(3)remove a usr
sudo userdel -r usrname
sudo rm -r /home/usrname
13 permission
(1) reading permissions
ls -l
r read
w write
x execute it as a programes
(2) changing permissions
chmod
chmod +options filename
chmod 777 file name
first 7 for user, second 7 for group, last 7 for other
read 4, write 2, execute 1
so it is 7 in total
chown
change the group of files
the syntax is the same as the chmod
14 echo and create variables
create the string into a variable
mind: no spacebar
jieyin@jieyin-HP-Pavilion-14-Notebook-PC:~$ ww="hello u"
jieyin@jieyin-HP-Pavilion-14-Notebook-PC:~$ echo ww
ww
jieyin@jieyin-HP-Pavilion-14-Notebook-PC:~$ echo $ww
hello u
15 find
(1)
to find the file in the dir
or only cd to ~
and then cmd 'find filename'
and it will start to find the file
(2)
cmd 'find /foldername -name partofthename*'
(3)
sudo find / -name filename
to find from the original file
(4)
to find the file updated in 1 day, or several days
find /foldername -mtime -1
- +
16 creating scripts
nano fileanme
and then enter '#! /bin/bash'
and then write some cmd
use chmod to change the permission
if you need to execute this file
should cmd './filename'
17 alias
define a brief cmd for a cmd
a way to create one's own cmd
delete the alias, use the cmd 'unalias'
jieyin@jieyin-HP-Pavilion-14-Notebook-PC:~$ alias ww='echo uu'
jieyin@jieyin-HP-Pavilion-14-Notebook-PC:~$ ww
uu
just type 'alias', it will show you all the defined alias
jieyin@jieyin-HP-Pavilion-14-Notebook-PC:~$ alias
alias alert='notify-send --urgency=low -i "$([ $? = 0 ] && echo terminal || echo error)" "$(history|tail -n1|sed -e '\''s/^\s*[0-9]\+\s*//;s/[;&|]\s*alert$//'\'')"'
alias egrep='egrep --color=auto'
alias fgrep='fgrep --color=auto'
alias grep='grep --color=auto'
alias l='ls -CF'
alias la='ls -A'
alias ll='ls --color -l'
alias ls='ls --color'
alias ww='echo uu'
18 .bashrc file
19 changjing passwd
cd to the home dir
and cmd 'passwd'
20 which
where the cmd locates
cmd 'which cmd'
21 whatis
show what the cmd means
cmd 'whatis cmd'
22 viewing resource
(1) df df -h
to read the info. of the file in the file system
df -h is for human to read
(2) du du -h du -s
show how much space was used
du -s for the summary
(3) free free -m free -h
to see the free storage
mind the buffer/cache
23 clear
same as that cmd in matlab
24 watch
to show the output repeatedly..
cmd 'watch cmd'
to quit 'ctrl c'
cmd 'watch -n second cmd'
to change the refresh second
'watch df -h' could see the progress of the downloading, logging or ram or storage
25 handle the file names and the folder names
nano mkdir
nano test\ file
nano test file
the first one is to create one file, the second one is to create 2 files
26 tab
to fullfill the whole file name
27 file
cmd 'file filename'
to show you what type is the file
28 sudo apt-get install packagename
29 apt-get
(1) sudo apt-get install programname
(2) sudo apt-get --purge programname
to remove a package
30 cowsay "the word you wanna show"
31 head
to show the top 10 lines of the file in the window
'head -n2' to show the only 2 line of the file
32 tail -f
look at the changing files
33
(1)
ls /home/jieyin > optseq2
ls /home/jieyin 1> optseq2
to write the dirname of /home/jieyin onto the optseq2
(2)
ls /home/jieyin 2> optseq2
to clear the file optseq2
(3)
echo "text some words" 1> filename
to add new content to the file
(4)
echo "add more things into" 1>> filename
remember that >> is not to overwrite
Copyright © 2003-2013 www.wpsshop.cn 版权所有,并保留所有权利。