What are some commonly used UNIX shell commands?

Creating a Directory

 

You can create a directory by using the mkdir command. For example, to create a directory named images within the current directory:

mkdir images

Changing your Current Working Directory

At any given time, you are located in some current working directory within the Unix file tree. When you log in, your current directory is set to your home directory.

You can change your current working directory any time by using the cd command (this stands for "change directory"). For example, if the current directory has a subdirectory named details, you can change to that directory using the command:

cd details

You can always find out the absolute pathname of the current working directory by typing the command:

pwd

You can return to your home directory by typing:

cd ~

Finding out what Files you Have

You can see what files you have by using the ls command:

ls

This command will give you a list of all the names of your files.

Making a Copy of a File

If you want to make an exact copy of the contents of a file, figure out what you want to name the copy, and then type the command

cp oldname newname

where oldname is the name of the existing file you want to copy. A new file will be created with the name newname and the same contents as the original.

Changing the Name of a File

The Unix mv command can be used to change the name of a file:

mv oldname newname

This will not affect the contents of the file. It will simply change its name from oldname to newname.

Getting Rid of Unwanted Files

Once you have no more need for a file, you can get rid of it permanently by using the Unix rm command.

Warning! When you remove a file, it is gone forever. There is no easy way to get it back. Please be careful that you do not remove a file that you really need.

To delete a file from your account, enter this command:

rm filename

where name identifies the file you want to remove.


You can remove more than one file at a time. For example, this command

rm image1.gif page.html test.txt

would remove the three named files.

  • 0 Users Found This Useful
Was this answer helpful?

Related Articles

How do I launch SSH or Shell Access tools?

Overview SSH (Secure Shell) is a program to log into another computer/server over a network...

How do I find information on other UNIX commands?

The UNIX command line interface is wonderful. With that power comes complexity if only in the...

How do I create a symbolic link?

A symbolic link is a pointer to another file or directory. It can be used just like the original...

How do I create a tar archive of a directory?

A common task in UNIX operating systems is creating an archive of many files or directories in a...

How do I find files and directories?

To search the current directory and all subdirectories for a folder or file, use the following...