User Tools

Site Tools


Chapter 03: Fundamental Command Line Skills


The course material explains some pretty basic stuff like cd, pwd, ls and the like. So I will probably not cover every subchapter.


The default shell is bash.
Other shells can easily installed with yum.

other Shells

name Description
bash The default Bourne-Again shell.
dash A simpler shell with fewer features than bash, but faster.
tcsh An enhanced version of the Unix C shell.
zsh A sophisticated shell, similar to the korn shell.

The default shell of a specific user can be changed in /etc/passwd.

Terminal Consoles

By default, six command line consoles are available on RHEL systems.
If a GUI is installed it takes /dev/tty1.

These settings, including the x tty can be changed in:

  • /etc/init/start-ttys.conf

Active consoles are defined as device files /dev/tty1 through /dev/tty6.

Changing ttys

Usually you can access the consoles with ALT-F1 - F6. However, on RHEL Systems with a GUI Alt-F2 is used to start the Run Application tool; therefore, you'll need to press CTRL-ALT-F2 to move to that second virtual console.

Graphical Consoles

If a Desktop Environment like GNOME or KDE is installed you usually have some graphical terminals as well.
The upside of graphical environments are features like tabs, windows, copy and paste etc.

Differences Between Regular and Administrative Users

Regular user:

[user@host ~]$

Administrative User:

[root@host ~]#



Text Streams and Command Redirection

Linux uses three basic data streams. stdin, stdout and stderr. You can redirect these streams to or from a file.


# database < datafile

Standard input can come from the left side of a command as well. For example, if you need to srcoll through the boot messages, you can combine the dmesg and *less commands with a pipe:

# dmesg | less

The output from dmesg is redirected as standard input to less.


# ls > filelist

To append the output to a file use:

# ls >> filelist
# Or to be sure:
# ls >\> filelist


# program 2> err-list

Standard Command Line Tools

File and Directory concepts

Environment PATHs

(~) skull@dc:$ echo $PATH

(~) root@dc:# echo $PATH

File Creation Commands


ln creates a link in the file system. There are two kinds of links: soft links and hard links.

The difference:

  • Hard links include a copy of the file. As long as the hard link is made within the same partition, the inode numbers are identical. That means if you delete the original, the link is removed as well.
  • Soft links only create a redirect. That means, if you delete the original, the link is there and just points to no valid file any more.

To create a hard link:

# ln /etc/samba/smb.conf ~/smb.conf

To create a soft link:

# ln -s /etc/samba/smb.conf ~/.smb.conf

File Searches



# find / -name named.conf

This search can take some time, because the parameter '/' tells find to start search in the root directory.
To specify another directory just use:

# find /usr -name named.conf

If you don't know the name of the file you can use wildards.

Wildcard Description
* Any. That means any alphanumeric character.
? One. One single alphanumeric character.
[] Range. A Range of options. For example, the ls ab[123] command would return the following filenames: ab1, ab2, ab3.


For a faster file search you should use locate. It is installed on common RHEL System. If not:

# yum install mlocate


# locate filename.txt

Locate uses a database which gets updated once a day. To update the database manually use:

# /etc/cron.daily/mlocate.cron

Or alternatively:

# updatedb

The Management of Text Files

Most files in Linux are text files. To actually look up the filetype use the file command.

(~) root@dc:# file /etc/samba/smb.conf
/etc/samba/smb.conf: UTF-8 Unicode English text

Commands to Process Text Streams


Prints the whole file.

less and more

less and more display the content of a file on the screen and separates it into pages.

Command Description
space One page forward.
pgup and pgdown Navigate through the pages.
/something Searches for 'something'. Navigate through the results with n and N like in vi.
q Quit.

One of the advantages of less over more is that less can actually read compressed files in .tar.gz archives.

Local Online Documentation

A Networking Primer

Network Configuration and Troubleshooting

linux/rhcsa/chap3.txt · Last modified: 2013/03/01 16:06 by