Linux Command Line (Basic Commands)

Tags Linux

Linux Command Line

Last modified by SDSU Research Computing on 2021/06/08 08:49

The following are some basic commands that are necessary to interact with files, folders, and applications on the Linux CLI (command line). Keep in mind that capitalization counts!

This list is not comprehensive and is just meant to be a starting point.

There are several online Linux resources you may find helpful, including Explain Shell and Learn Shell..

Command Effect Usage
cat Prints the contents of one or more files onto your screen.
cat [filename]
cd Changes the directory you are working in.
With no specified directory, it will send you to your home directory (~)
cd [directoryname]
To go up a level: cd ..

Copies files or directories to another location.  
For example, moving a file or directory to your /scratch location.  Use -r to recursively copy directories.

cp (-r) sourcefile1 or directory .. targetdirectory
du Used to check your disk space usage.  
For example, du -h /home/first.last will print the amount of storage you are currently using.
du -h /home/chad.julius --max-depth=1
less Allows paging through a file.
In contrast to cat, you can use the page up /page down keys to navigate the file one page at a time.
less filename
ls or ll

Lists the contents of the current directory. 'll' will provide a long list.

ls [options]
To view hidden files: ls -a
man Displays the manual page for any command.
This will include how the command's arguments, options, and examples of its use.
man [command]
mkdir Creates one or more directories in the current directory.
mkdir [directoryname]
mv Moves a file. If the target does not exist, the source file is renamed to the name of the target.
If the target exists and is the name of a directory, then all files listed as a source file will be moved to the directory.
mv sourcefile1 sourcefile2 .. targetfile/directory
pwd Returns the path of the current directory. This is useful to make sure you are in the correct directory.
rm Deletes one or more files. Use -r in options to remove directories as well.
rm [options] file1 file2 ...
rmdir Deletes any empty directories. Use this instead of rm -r to ensure files are not accidentally deleted.
rmdir [directoryname]
scp Copies file or directories from a remote server to working server or vice-versa.  
Use -r to recursively copy directories.
scp (-r) sourcefile1 or directory chad.julius@pt:/targetdirectory
tail Displays the last few lines contained in a file. This is useful to see recent changes that are appended to a file.
tail filename

Advanced Linux Command Line on SDSU Systems

The above command line examples will give you a great start on navigation, manipulating files and directories, and other basic commands.  They are probably the most used examples when it comes to basic command line usage.

Was this helpful?
0 reviews
Print Article


Article ID: 135672
Fri 12/3/21 12:31 PM
Fri 12/15/23 12:08 PM