command |
meaning |
usage example |
date |
out put the date |
date |
echo |
print out its arguments |
echo hello
echo hello/ world
echo "hello world" |
$PATH |
is an environment variable that lists which directoried the shell should search for program when it is given a command |
echo $PATH |
which |
find out which file is executed for a given program name |
which npm |
pwd |
the absolute pathname of the current working directory |
pwd |
cd |
change the current working directory |
cd /
cd ./xx/
cd ../.. |
. |
current directory |
|
.. |
parent directory |
|
ls |
list files |
ls
ls /
ls -l |
mv |
move file |
mv a.txt b.txt
mv a.txt ../b.txt |
cp |
copy file |
cp a.txt b.txt
cp a.txt ../b.txt |
rm |
remove file |
rm a.txt
rm -rf ./xxDirecotry |
rmdir |
remove directory |
rmdir ./xxEmptryDirectory |
mkdir |
make directory |
mkdir directoryName |
man |
manual page |
man cp |
ctrl L |
clear and go back to the top |
|
< file |
rewire the input for this program to be the contents of this file |
cat < hello.txt |
> file |
rewire the output of the preceding program into this file |
echo hello > hello.txt
cat < hello.txt > hello2.txt |
cat file |
print the content of the file |
cat hello.txt |
>> |
append instead of overwrite |
cat < hello.txt >> hello2.txt |
| |
take the output of the program to the left and make it the input of the program to the right |
ls -l / | tail -n1
ls -l / | tail -n1 > ls.txt
curl --head --silent taobao.com | grep -i content-length | cut -d ' ' -f2 |
tail |
prints the last n lines of its input |
tail -n1 |
curl |
|
|
grep |
|
|
cut |
|
|
sudo |
do as super user |
|
sudo su |
get the shell as the super user |
|
tee |
take it input and write it to a file but also to standard out |
echo 1060 | sudo teee brightness |
find |
|
|
xdg-open |
|
https://www.youtube.com/watch?v=Z56Jmr9Z34Q
https://missing.csail.mit.edu/2020/course-shell/