Unix commands tutorial with examples

This article is about Unix commands tutorial with examples, This is my third session on Unix basics and it will help you to know, how to copy the files and many more about Unix basics.

Unix commands tutorial with examples

1] Copying Files

unix commands tutorial : cp (copy)

unix commands tutorial
Unix commands tutorial :cp (copy) command example

 

unix commands tutorial : cp (copy) explains the detailed procedure about how to use the command as well as how it works.It is explained as follows

cp file1 file2 is the command which makes a copy of file1 in the current working directory and calls it file2

Use the cp command to copy it to your unixstuff directory.

First, cd to your unixstuff directory.

% cd ~/unixstuff

Then at the UNIX prompt, type,

% cp /vol/examples/tutorial/science.txt .

The above command means copy the file science.txt to the current directory, keeping the name the same.

(Note: The directory /examples/tutorial is an area to which everyone in the department has all read and copy access. If you are from outside the University campus, you can take a copy of the file here. Use ‘File/Save As..’ from the menu bar to save it into your unixstuff directory.)

2] Moving files

unix commands tutorial : mv (move)

unix commands tutorial
unix commands tutorial : mv (move) command example

 


unix commands tutorial : mv (move) explains the detailed procedure about how to use the command as well as how it works.It is explained as follows

mv file1 file2 moves (or renames) file1 to file2

To move a file from one place to another place, use the mv command. This has the effect of moving rather than copying the file.

It can also be used to rename a file, by moving the file to the same directory, but provide it a different name.

First, change directories to your unixstuff directory. Then, inside the unixstuff directory, type

% mv science.bak backups/.

Type ls and ls backups to see if it has worked.

I am sure you readers will get more clarity about brief and line by line descriptions about provided commands, and I am also trying to provide you easy examples.

Now let’s move to next command,

3] Removing files and directories

unix commands tutorial : rm (remove), rmdir (remove directory)

unix commands tutorial : rm (remove), rmdir (remove directory) explains the detailed procedure about how to use the command as well as how it works.It is explained as follows

To remove a file, use the rm command. Example, we are going to create a copy of the science.txt file then delete it.

Inside your unixstuff directory, type

% cp science.txt tempfile.txt

% ls (to check if it has created the file)

% rm tempfile.txt

% ls (to check if it has deleted the file)

You can use the rmdir command to remove a directory (make sure it is empty first). Try to remove the backup folder directory.

you can also read our other blog like unix command tutorials for beginners

Soon, I will publish my next session on unix commands and let me know if you have any concerns.

Thank you and If you like our blog please do visit again

Share This Post

Post Comment