Skip to content

Basic Linux Commands

An overview eight frequently-used Linux commands and examples of how to use them. For additional information about any of these commands, log onto an EECS machine and type man command.


The cd command changes the current (working) directory.

Command Effect
cd Changes to your home directory.
cd foo Changes to the foo directory.
cd .. Changes to the parent directory (i.e., move up one directory).


The cp command copies files and directories.

Command Effect
cp src-file dest-file Creates a copy of the file src-file named dest-file.
cp src-file dest-dir Copies the file src-file into the dest-dir directory.
cp -R src-dir dest-dir Copies all files and subdirectories within the src-dir directory into the dest-dir directory. (The -R stands for “recursive”.)
cp -i src dest Copies the file/directory src to the file/directory dest, but prompts if any files or directories would be overwritten. (The-i stands for “interactive”.)


The du command displays the amount of disk usage for specific files and directories.

prompt> du -sh ~
450M .

In the above example, the files in the user’s home area (denoted by ~) are occupying 450 megabytes of storage. (The two options s and h stand for “summarize” and “human-readable” respectively.)

By sorting the output, you can see which directories and files are consuming the most space:

prompt> du -sk ~ | sort -n
0 fork.c
0 nohup.out
1 Calendar
1 afile
1 cactus
16773 www-home
20922 classes
96336 gcc
196762 mail

(The k option stands for “show number of kilobytes”.)


The ls command lists directory contents.

Command Effects
ls Lists the contents of the current working directory.
ls dir-name Lists the contents of the dir-name directory.
ls -a Lists the contents of the current working directory, including files that begin with a dot. (Dotfiles are not listed unless the -a option is used.)
ls -l Lists the contents of the current working directory in long format.


The mkdir command makes (i.e., creates) a new directory.

Command Effect
mkdir foo Creates a new directory named foo.


The mv command moves or renames files and directories.

Command Effect
mv old-file new-file Renames the file old-file to new-file.
mv src-file dest-dir Moves the file src-file into the dest-dir directory.
mv old-dir new-dir Renames the old-dir directory to new-dir.
mv -i src dest Moves or renames src to dest, but prompts if any files or directories would be overwritten. (The -i stands for “interactive”.)


The rm command removes (i.e., deletes) files. (To remove directories, see the rmdir command below.)

Command Effect
rm foo Deletes the file foo.
rm -r dir Deletes the foo directory, including all of its files and subdirectories. (The -r stands for “recursive”.)
rm -i file Deletes the file foo, but prompts before actually deleting it. (The -i stands for “interactive”.)

“Safe” rm

Most EECS Linux accounts have an alias for the rm command resulting in a “safe” rm. Instead of removing files, they will be moved to your junk directory, ~/junk, which is periodically cleaned out. To determine if you are using “safe” rm, run the following command:

prompt> which rm
rm: aliased to /home/user/bin/safe_rm

If you want to use the “real” rm command, run /bin/rm from the command line. However, this command cannot be reversed (i.e., you cannot restore the deleted files). If you are unable to restore deleted files, see the EECS IT Support.


The rmdir command removes (i.e., deletes) empty directories.

Command Effect
rmdir foo Deletes the foo directory.

The flagship campus of the University of Tennessee System and partner in the Tennessee Transfer Pathway.