Linux/UNIX directories and shell commands for VARs

The Linux/UNIX directories and shell commands listed in this chapter excerpt will be valuable to solution providers who are trying to customize their customers' Linux environments.

Solution provider's takeaway: Managing your customer's Linux server will be much less tedious if you have a comprehensive knowledge of Linux/UNIX directories and shell commands. Read through the various options you have with environment customization and user profiles.

GUI vs. CLI

Since the first graphical user interface (GUI) was created in the Xerox Palo Alto Research Center in the early 1970s, those of us who work in information systems and technology have debated its merits and liabilities.

The real issue is not whether to use a GUI or a command-line interface (CLI); it is about choosing a tool that works for you and helps you work most effectively. For most of us, that means that sometimes we'll use a GUI and sometimes we'll use a CLI.

I once had a student in a Linux workshop who said his nickname was "No GUI Louie". While I remember Louie as a very knowledgeable and capable IT pro, I have also had students who avoid the CLI because of its complexity without considering the power it affords an administrator. I think we limit ourselves when we arbitrarily limit the tools at our disposal by eliminating GUI or CLI tools. In my own work, I find that I use both the CLI and GUI, depending on the task at hand and my personal familiarity with the tools in question. (Okay, I use the command-line most often, but I'm very grateful for the GUI when performing unfamiliar tasks!)

 

GUI Pros GUI Cons
Faster Farther away from the "road"
Fewer typing errors Less control
Less minutia Java and other issues might make GUI unavailable
Safer (harder to make mistakes) Some of the names and labels it creates are strange
Can help teach you CLI commands Some people are more familiar with the CLI

Linux Directories

Everything in Linux/UNIX is based on the file system. The file system is comprised of various directories (Windows calls them "folders".) The root directory ("/") is at the base of the file system. Some directories may be on different partitions or drives, but they are still a part of the file system. Some directories may even be on completely different computers, perhaps running a completely different operating system, but they are still part of the file system. What follows is a list of some of the more commonly found directories in the Linux file system (all directories are not included on all systems):

 

  • / is the root directory
  • /bin/ and /usr/bin/ store user commands.
  • /boot/ contains files used for system startup including the kernel.
  • /dev/ contains device files
  • /etc/ is where configuration files and directories are located.
  • /home/ is the default location for users‟ home directories.
  • /initrd/ is used to load required device modules and mount the initrd.img image file during system startup.
  • /lib/ and /usr/lib/ hold library files used by programs in /bin/ and /sbin/.
  • /lost+found/ holds orphaned files (files without names) found by fsck
  • /mnt/ holds the mount points for file systems that were mounted after boot.
  • /opt/ is used primarily for installation and unintallation of third-party software. Holds optional files and programs.
  • /proc/ is a virtual directory (not actually stored on the disk) which holds system information required by certain programs.
  • /root/ is the home directory of the superuser "root"
  • /sbin/ and /usr/sbin/ store system commands.
  • /tmp/ is the system temporary directory. All users have read+write access to /tmp/.
  • /usr/ contains files related to users such as application files and related library files ("usr" is an acronym that stands for UNIX system resources).
  • /var/ (as in "variable") holds files and directories that are constantly changing such as printer spools and log files.

The above is a brief overview of Linux/UNIX directories. For a more complete discussion of Linux/UNIX directory structures, search on "Filesystem Hierarchy Standard" at www.wikipedia.com.

Starting and Stopping Services

In Linux, the various services that together make up the entire operating system are called daemons (pronounced DEE-muns). There are daemons for the DNS name server (named), the Web server (httpd), DHCP (dhcpd), and so on. When you see odd names ending with the letter "d", you're most likely looking at a daemon name. Most of the daemons can be controlled through scripts located at /etc/init.d/. For example, to start the Web server from a terminal window, you would execute the command "/etc/init.d/httpd start". To stop it, you would execute the command "/etc/init.d/httpd stop".

Different Linux distros might place the scripts in slightly different locations. Later in the book, you'll learn how to use the find command to locate such scripts as well as other files and directories.

The Red Hat System-Config and System-Control Utilities

Red Hat-based systems include the system-config and system-control utility, a text and graphics-based utility to help you configure and manage various aspects of your system. You can see the available utilities by opening a terminal window and, as root, typing the following command:

#system-

Do not hit enter, but instead touch the tab key twice and you'll see a listing of options.

Figure 1 The Red Hat system utility

The Shell

The shell is the interface between the user and the operating system. It acts as a keyboard interpreter, taking the keyboard input from the user and delivering it to the operating system. You can think of the shell as being the part of the operating system that allows you to interact with the kernel. The shell is the program that executes Linux or UNIX commands.

There are several shells available for use in the Linux and UNIX. The one most commonly used in Linux is the bash shell (Bourne Again Shell). Other shells include sh (Bourne Shell), csh (CShell), tcsh, csh, and ksh (Korn Shell).

You can change the shell by typing the shell's name at a command prompt.

For the purpose of this document, we'll focus on the bash shell.

The shell is not only a command interpreter, it is also a scripting language. Experienced Linux administrators often write scripts to automate frequently conducted system tasks.

Linux, like all multi-user operating systems, has an administrator account which is used for system configurations and operations. In Linux/UNIX, the administrator account is called "root" (equivalent to "admin", "administrator", or "supervisor" in other operating systems). "root" is often referred to as the "superuser" because of the account's unrestricted access to every area of the system and every aspect of the system's configuration.

When logged on as root using the bash shell, the prompt is a pound sign (#). When logged on as a regular user using the bash shell, the prompt is a dollar sign ($).

Shell commands in the Linux/UNIX world are usually case sensitive.

You can see your default shell with this command:

#echo $SHELL

Linux Profiles

There are two types of Linux profiles: system-wide and user-specific. System-wide configurations affect all users, while user-specific configurations affect only a single user. Normally, you must be root to change system-wide configurations.

User-Specific Profiles

User-specific profile settings are found in the user's home directory (/home/donc), but they're hidden by prepending a "." to the filename. Examples of profile files include:

 

  • .bashrc
  • .bash_profile
  • .bash_history

There are many others. You can view the hidden files in any directory by using "ls -a".

System-Wide Configurations

System-wide configuration settings are almost entirely found in /etc. This is where you find files for configuring Apache, BIND DNS, and nearly any other aspect of Linux. For example, in Debian Linux, if you want to modify settings of your Apache Web server, you would probably modify /etc/apache2/apache2.conf. If you are working with a Red Hat product, the file most likely is /etc/httpd/conf/httpd.conf. (The reason for using tentative language is because everything is configurable in Linux and the person who built your Linux system might have chosen to place the configuration files elsewhere.)


Linux Administration
  Linux/UNIX directories and shell commands for VARs
  Working with configuration files in Linux systems

Don R. Crawley is the president and chief technologist of the Seattle-based IT training company, soundtraining.net. He has more than 35 years experience working with workplace technology and automation and holds multiple technical certifications including Linux+ and CCNA Security.

Printed with permission from Soundtraining.net. Copyright 2010. The Accidental Administrator: Linux Server Step-by-Step Configuration Guide by Don R. Crawley. For more information about this title and other similar books, please visit www.soundtraining.net/bookstore.

This was first published in January 2011

Dig deeper on Server Operating Systems: Windows, Linux and Unix

Pro+

Features

Enjoy the benefits of Pro+ membership, learn more and join.

0 comments

Oldest 

Forgot Password?

No problem! Submit your e-mail address below. We'll send you an email containing your password.

Your password has been sent to:

MicroscopeUK

SearchCloudProvider

SearchSecurity

SearchStorage

SearchNetworking

SearchCloudComputing

SearchConsumerization

SearchDataManagement

SearchBusinessAnalytics

Close