Unix Essentials
- Unix commands are typed at the command line after the prompt
- They usually have the form
COMMAND OPTION ARGUMENT(S)
- Where the option is preceded by "-" or "--"
- We can hit the Enter key to execute the command
- We can type part of the file name, then hit the Tab key to complete the rest
- We can run the previous commands again, just hit the up arrow key, ↑
- We can abort the program by holding down Control key while hitting C
- Here are more useful shortcut keys
- Ctrl A - Moves the cursor to the beginning of the line
- Ctrl E - Moves the cursor to the end of the line
- Ctrl D - Logs out of the current session
- Ctrl U - Erases the complete line
- Ctrl R - Allows you to search for a previously used command or switch
Basic Unix Commands
- To list the contents of the current directory; ls stands for list
ls
- To go to a new directory; cd stands for change directory(same thing as folder)
cd NAME_OR_ADDRESS_OF_DIRECTORY
- To reveal the current directory; pwd stands for print working directory
pwd
touch FILENAME
- To remove a file; rm stands for remove
rm FILENAME
- To create a new directory; mkdir stands for make directory
mkdir DIRECTORY_NAME
- To remove a directory; The directory must be empty or rmdir will not work
rmdir DIRECTORY_NAME
- To move a file to another place; mv stands for move
mv FILENAME NEW_DIRECTORY
- We can also use mv to change the name of a file or directory
mv CURRENT_NAME NEW_NAME
- To see the contents of a file; cat stands for concatenate
cat FILENAME
- To make a new copy of a file; cp stands for copy
cp ORIGINAL_FILENAME NEW_FILENAME
File transfer in Unix
- To download a file remotely from a Unix server
scp SERVER_ADDRESS:FULL_PATH_OF_FILE/FILENAME ~Desktop/FILENAME
Ex:
scp woodylin@users.cs.umb.edu:/home/offner/cs450/lectures/lec01.pdf ~/Desktop/lect01.pdf
Noted that "~" is the same thing as "/Users/woodylin"
- To download a directory remotely from a Unix server; -r is the OPTION which means that recursively copy the entire directory.
scp -r SERVER_ADDRESS:FULL_PATH_OF_FILE/FILENAME ~Desktop/FILENAME
- To upload a file from the local machine to a Unix server
scp FILE_PATH SERVER_ADDRESS:FULL_PATH_OF_FILE/FILENAME
Reference
Comments
Post a Comment