Shell learning 1

What is shell

Basic shell command

remmanber use TAP in your keyboard, which can make you type more easier.

quckly to copy and pasta command are ctrl + shift + c/v in linux, other is same with your system

any command you can use [command] --help to search what you want command .

cd

cd can show to current directory or back to parent directory

two cmd

go to current directory at directory

cd /home

back to parent directory

cd ..

ls

Show the files in current directory

ls

show the owner and information of files in the current directory

ls -l

seach parent directory files

ls ..

mv

change file name, such as 111.txt rename 123.txt

mv 111.txt 123.txt

cp

copy file from 111.txt rename to 123.txt

cp 111.txt 123.txt

Copy files from current directory to parent directory and rename from 111.txt to 144.txt

cp 111.txt ../144.txt

rm & mk

remove file from parent directory, such as remove 144.txt from parent directory.

rm ../144.txt

remove current directory of directory, such as remove a empty directory 111 in current directory.

rmdir 111

create a dirctory in current directory

mkdir myphoto or mkdir "my photo"

Manual

it is can show the detail information about the command, such as want to know the rm detail information

man rm

q can quit the manual

Clear Terminal

keyboardcontrol(crtl) + L or clear clear terminal and go back to top

<> angle bracket

< is input meaning

> is output meaning

such as

echo hellow > hellow.txt Which is mean hellow is output into the hellow.txt files.

cat can print the file contents, such as

cat hellow.txt

also we can input the hellow.txt file in the cat, such as

cat < hellow.txtwhich would be print the hellow on the shell

what that means, let’s go to do another example,

when cat input the hellow.txt, we can output the hellow.txt contents to another files or new create files.

cat <hellow.txt > hellow2.txt that wil carrier the hellow.txt contents to hellow2.txt contents.

>> meaning appends

cat < hellow.txt >> hellow2.txt which is means copy contents from hellow.txt to hellow2.txt but appends not cover.

| pipe charater

take the output of the program to the left| input in the left.

such as

ls -l/

tail -n1 which is mean output the ls -l last informatiom of the ls -l

ls -l / | tail -n1

if we connect the angle bracket to use this cmd, such as

ls -l / | tail -n1 > ls.txt there will wirte the last one information in the ls.txt

How to find the file in linux or mac

sudo find -f -name filename

xdg-open filename

  • Copyrights © 2022-2024 Jessy Huang
  • Visitors: | Views:

请我喝杯咖啡吧~