Skip to content

Latest commit

 

History

History
61 lines (49 loc) · 2.45 KB

Handy_Unix_Tips.Md

File metadata and controls

61 lines (49 loc) · 2.45 KB

Helpful unix commands

Started with help from https://www.tipsandtricks-hq.com/basic-unix-commands-list-366

THERE IS NO EASY WAY TO UNDO (like control Z), so please double check your work when you use these commands!

File/Directory operation related Unix Commands

cp – copy a file.
The example below copies the file "file.txt" from the directory /proj/ to /proj/lkw
> cp file.txt /proj/ proj/lkw

mv – move or rename files or directories.
The example below moves the file "file.txt" from the directory /proj/ to /proj/lkw
> mv file.txt /proj/ /proj/lkw
The example below renames the file "file.txt" to "newfile.txt"
> mv file.txt file2.txt

tar – create and use archives of files.

gzip – compress a file.

mkdir – make a directory.
The example below will make a directory/folder called "lkw" in the folder /proj/users
> mkdir /proj/users/lkw
If you are already in the /proj/users directory, all you need to do is:
> mkdir lkw

rm – remove files or directories.
rmdir – remove a directory
I dont recommend these for new users. Instead, make a directory called "trash" and move your bad files/directories into there.

> mkdir trash
> mv badfile.txt baddirectory trash



Navigational type Unix Commands

cd– change directory.
The example below will change directories to /proj/users/lkw
> cd /proj/users/lkw

pwd – display the name of your current directory.
> pwd

ls – list names of files in a directory. The command ls -l will give you more information than just ls
> ls -l

Display file content

cat – concatenate and display files.
more – The more utility is a filter that displays the contents of a text file on the terminal, one screenful at a time.
less – Less is a program similar to more (1), but which allows backward movement in the file as well as forward movement. Also, less does not have to read the entire input file before starting,so with large input files it starts up faster than text editors like vi


File Editing

nano – nano is a small, free and friendly editor. More information can be found here https://www.howtogeek.com/howto/42980/the-beginners-guide-to-nano-the-linux-command-line-text-editor/