Mac Terminal Use Tricks to Switch to Other Paths and Directories

     If you want to switch the current command line session to another directory, three commands are needed: pwd, lsand cd.

  1. pwdThe meaning is "print working directory", which will display the absolute path of the current directory.
  2. lsThe meaning is "list directory contents", it will list the contents of the current directory. There are other optional parameters for this command.
  3. cdThe meaning is "change directory", it will change the current directory to the directory you specify. If you don't specify, it will return your home folder.

       

pwd current working directory

cd (without parameters) into root

cd (folder) to enter the folder

cd .. parent directory

cd ~ back to root

cd - go back to the last visited directory

rm filename delete

cat filename (|less) View the file under the terminal

ls lists all files in a directory

cp filename target directory to copy the file to the target directory

~ represents root such as: ~/Document/CPP2/

mkdiv new folder

g++ source file name compiles the source file, producing a.out

./filename run Example: ./a.out <input filename> output filename

control+d interrupt a.out running

nano write scripting language ctrl+o storage

nano ....sh open

bash ....sh run script

echo "...$i..." output statement

tar -zxf abc.tar.gz tar file decompression

ssh [email protected] Connect to the 222 server remotely with the root account

unrar x abc.rar rar file decompression, need to install rar tool

Guess you like

Origin http://43.154.161.224:23101/article/api/json?id=324767800&siteId=291194637