Monday, January 16, 2017

Basic Linux Commands

Here is a short list of basic, but essential commands. In Linux, commands are case-sensitive and more often than not they are entirely in lowercase. Items that are surrounded by brackets ( [] ) are optional. You will more than likely use at least some of these commands every time you log into a Linux system. Become familiar with these commands because they can get you pretty far in a short amount of time.

ls - Lists directory contents. You will use ls to display information about files and directories.

cd [dir] - Changes the current directory to dir. If you execute cd without specifying a directory,
cd changes the current directory to your home directory. This is how you navigate around the system.

pwd - Displays the present working directory name. If you don't know what directory you are in, pwd will tell you.

cat [file] - Concatenates and displays files. This is the command you run to view the contents of a file.

echo [argument] - Displays arguments to the screen.

man command - Displays the online manual for command. Type q to quit viewing the manual page.
The documentation provided by the man command is commonly called "man pages."

exit , logout , or Ctrl-d - Exits the shell or your current session.

clear - Clears the screen.

Here is a capture of Bob's session using the above commands.

$ ls
PerformanceReviews sales-lecture.mp3 sales.data tpsreports
$ cd tpsreports
$ pwd
/home/bob/tpsreports
$ ls -l
total 2
-rw-r--r-- 1 bob users 31 Sep 28 14:49 coversheet.doc
-rw-r--r-- 1 bob users 35 Sep 27 08:47 sales-report.txt
$ cat sales-report.txt
We sold lots of widgets this week!
$ echo $PATH
/bin:/usr/bin:/usr/sbin:/usr/local/bin
$ man ls
NAME
ls - list directory contents
...

No comments:

Post a Comment