Transitioning from Windows to Linux administration: A guide for newcomers, Part II

Featured Content

This article is courtesy of TechRepublic Premium. For more content like this, as well as a full library of ebooks and whitepapers, sign up for Premium today. Read more about it here.

Join Today

Windows and Linux are operating systems with many similarities and differences. Learn some tips to help cross the bridge between the two in the second of a multi-part series.

In the first installment of this series we took a look at the history of Linux and how it has grown into an essential force in many enterprise data centers. We also discussed some of the ways in which Windows and Linux are both similar and different, with the goal of helping to orient new Linux administrators with a background in Windows operations.

The entirety of this series will focus on the following introductory Linux concepts:

  • Creating and managing user accounts, passwords and groups
  • Working with files, directories and permissions
  • Granting administrative privileges
  • Installing programs/services and setting startup processes
  • Managing running processes
  • Working with user environments
  • Formatting drives/partitions
  • Mounting devices/configuring, accessing and sharing network resources
  • Working with shell scripts
  • Troubleshooting/checking logs
  • Useful Linux command-line tricks
  • Getting free help/resources for further information

In Part I, we examined these three Linux concepts and how they work:

  • Creating and managing user accounts, passwords and groups
  • Working with files, directories and permissions
  • Granting administrative privileges

In this second installment of the series we'll move on to cover the following topics:

  • Installing programs/services and setting startup processes
  • Managing running processes
  • Working with user environments

Enjoying this article?

Download this article and thousands of whitepapers and ebooks from our Premium library. Enjoy expert IT analyst briefings and access to the top IT professionals, all in an ad-free experience.

Join Premium Today

As stated in Part I, prerequisites for users of this guide are familiarity with concepts of system administration such as creating users, working with permissions, managing programs and processes, configuring hardware such as network details and hard drives and reviewing event logs for errors.

1. Installing programs/services and setting startup processes

Installing programs

Windows programs generally install to the C:\Program Files or C:\Program Files (x86) directories (the latter for 64-bit systems running 32-bit programs). It's a bit less predictable with Linux; programs might install to the /usr/bin, /usr/sbin, /usr/local/bin folders or another location such as a home directory or the directory in which a user just happened to run an installer.

If you know the name of the installed Linux program you can find out where it resides by using the "which" command. For instance:

which firefox 

Will return something like:

/usr/bin/firefox

A major difference between Windows and Linux is that Windows installs programs through executables ("setup.exe" for instance) and Linux generally uses a package manager program, whereby packages are software installers (these may end in .rpm for Red Hat Linux since this stands for "Red Hat Package Manager).

Installing programs using the graphical user interface (GUI) in Linux works in a similar fashion to Windows. Unlike Windows there are several available GUI options for Linux (Gnome and KDE being two examples), however the process of installing programs is the same; you download the installer (also known as a package) from the internet or access it from installation media such as DVDs or flash drives. The installer is run simply by double-clicking it and following prompts.

As with Windows, you have to have the appropriate permissions to install software in Linux, of course, so throughout this article all instructions assume you have root permissions.

Here is an example of installing Chrome for Linux from Google's website using the GNOME interface:

linux-2.png

You can leave the Package installer as the default program to open this file and click OK. The file is then downloaded.

linux-3.png

Once the download completes the installation process begins.

linux-4.png

Here it's simply a matter of clicking "Install" and waiting for the process to finish.

Installing programs via the command line in Linux is a bit different than in Windows and there are multiple ways to do this depending on which type of Linux distribution you're working on. You can download files from the internet via the command line using the wget command followed by the URL of the file. For instance to install a program called Webmin, which is a web-based interface for system administrator for Linux type:

wget http://prdownloads.sourceforge.net/webadmin/webmin-1.700-1.noarch.rpm

If you use a proxy server you'll need to provide the relevant information when using wget; this appears in the form of wget [URL]:[proxy password]@[proxy IP or name]:[proxy port] - for instance:

wget http://prdownloads.sourceforge.net/webadmin/webmin-1.700-1.noarch.rpm:password@10.1.1.1:8080

This will produce output similar to the following:

linux-5.png

This will show the .rpm file being downloaded to the local directory. You can then run this command to install the file (remember, you have to have the appropriate privileges):

rpm -U webmin-1.700-1.noarch.rpm

You can see the results here:

linux-5a.png

By the way, Webmin is a fantastic interface for new Linux administrators to learn more about and configure their systems. It shouldn't be used in place of the commands you ought to learn to maximize your understanding of Linux, but it can help you learn about your system and what it does as you build more experience. When installed, Webmin it sets up a local web server interface with many useful options:

linux-6.png

It's also possible to use the command line to download a zipped file containing source files which need to be compiled to install and run. These zipped files usually end in .bz or .gz and can be downloaded using wget. You then need to use the local tar command to extract them.

To install source files from a file ending in .bz:

tar -xfv filename.tar.bz 

This extracts the contents to a new folder corresponding to the "filename" listed in the .bz file.

To install source files from a file ending in .gz:

tar xzvf filename.tar.gz

(This is also known as a tarball)

This command extracts the contents to a folder corresponding to the "filename" listed in the .gz file (it may or may not include the version number).

Now type these commands:

cd “filename” (whereby “filename” represents the folder created in the previous step) 

./configure
make

make install (or sudo make install if you need elevated privileges)

For example, to download and install an image editor called ImageMagick enter:

wget http://www.imagemagick.org/download/ImageMagick.tar.gz

This will connect to the site listed and download the file:

linux-7.png

Typing tar xzvf ImageMagic.tar.gz extracts the files to a folder called Imagemagick-6.8.9-7.

You can type ls -l to verify:

linux-8.png

Use cd Imagemagick-6.8.9-7 to enter the directory.

Run ./configure to prepare the program for installation

(When running some executables within a specific folder prefix it with "./" without the quotes to tell Linux to run from that folder, otherwise you would have to specify the full path which in this case would be /home/root/ Imagemagick-6.8.9-7).

You should see activity indicating various factors are being checked and folders/files created as shown:

linux-9.png

When this finishes you will return to the command prompt. Type:

make

This will begin compiling the program:

linux-10.png

When finished, run make install which copies the compiled files into their appropriate locations. Once this is done, the program is ready for use; in the case of ImageMagic various executables can be run to start editing images (these are signified by the "x" permission as discussed in Part I; running ls -l will show this information).

The above methods work well enough for one-off installations, but there is a bigger picture available in the form of bundles of applications from which you can pick and choose what you want to install. These are known as package repositories (or collections), and can exist as a local repository on the system itself (such as a DVD containing software packages) or on another server (within the network or on the internet, for instance).

The concept of a repository may seem confusing overkill. After all, with Windows you just run the executables you want to kick off, such as Microsoft Office, Adobe Reader or antivirus program installations, then when you're done the system will be set up the way you want it. The advantage of a repository in Linux is that it lets you add the programs you like from one or many centralized sources. It's generally easier to rely on your Linux package manager to add most if not all programs you may want to install, rather than loading them from installation media or downloading them separately. You can also update them from this single source when newer releases come out (assuming it's a live repository).

This article focuses on Red Hat Linux (generally the business standard), and Red Hat uses the "yum" (Yellowdog Updater, Modified) or "rpm" (Red Hat Package Manager) commands to install software. Yum is generally preferred since it offers more options and can install or update packages more easily, and it has more native repository functionality. Both commands (where applicable) will be described below.

Setting up a repository

First you have to set up the repository so Linux knows about it and where to find the packages it contains. Repository information can be kept in a file called /etc/yum.conf or in a text file (generally a .repo file) kept in the /etc/yum.repos.d folder. Multiple files can exist in this folder.

Yum will read the contents of all files and, assuming the repositories configured herein are enabled (which this article will show you how to do), will know where to find the necessary information. Using multiple repository files is handy if you need to add temporary or multiple selections.

To set up a repository of packages from the Red Hat Enterprise Linux DVD

This is the simplest method and best to start out with if you're a novice. Insert the Linux DVD in the drive of the system (or mount it as an .iso if this is a virtual machine).

You'll probably notice the DVD appears as available in the GUI, but it needs to be mounted for use in a command (or terminal) window. Remember there are no drive letters in Linux; folders and volumes are prefaced with the / sign.

Open a terminal prompt in Linux as root.

Type:

mkdir /mnt/dvdrom

This sets up a mount point for the DVD media in a directory called dvdrom under the main mnt folder.

Now mount the CD/DVD ROM in the dvdrom directory:

mount /dev/dvd /mnt/dvdrom

Confirm you can read files from the DVD via the terminal window by typing:

cd /mnt/dvdrom
ls

You should then see a listing of the contents of the DVD.

Now you'll need to create a .repo file to access packages on the DVD. This involves creating a file called rheldvd.repo under /etc/repos.d directory.

Type:

vi /etc/repos.d/rheldvd.repo

This creates a blank text file in the vi editor.

Press the Insert key to begin entering data. Add the following details.

[dvd]
name=Red Hat Enterprise Linux Installation DVD
baseurl=file:///mnt/dvdrom/Server
enabled=1
gpgcheck=0

Save and exit the file via :wq!

The "[dvd]" entry signifies this is a DVD, which signifies where the packages are located.

The "baseurl" entry points to the "Server" folder on the DVD which stores the packages. (if you are using a different DVD make sure the folder you specify contains .rpm files and a repodata folder)

The "enabled=1" entry signifies that this repository is enabled.

The "gpgcheck=0" entry tells yum not to perform a GPG check on packages for security (this is acceptable since it's your installation DVD).

You can confirm yum sees the repository by typing:

yum repolist enabled 
linux-11.png

It's also possible to set up a more advanced repository based on an internal or public internet site. First let's take a look at how to work with yum then we'll discuss how to use a website for a repository.

Working with packages

First let's see which packages are installed.

Type:

yum list installed (or rpm –qa)
linux-12.png

The screen above is simply an example of which packages may be present; your system might vary.

To see if a specific package is already installed type:

yum list installed {packagename} (or rpm –qa | grep {packagename}. 

For instance, to see if Firefox is installed, type:

yum list installed firefox
linux-13.png

The above screenshot shows firefox is indeed installed.

To show the packages you can install type:

yum list available (or rpm –qa)
linux-14.png

You will see a screen similar to the above. There are obviously quite a few entries here, so to search for a particular package use "yum search." For instance:

yum search adobe

This will show you any Adobe-related packages such as the following:

linux-15.png

You can find more information about a package by using "yum info {packagename}" (or rpm -qi {packagename}. For instance, to find out more about a package called zoo.x86_64 type:

yum info zoo.x86_64
linux-16.png

If you wanted to install zoo.x86_64 you would type:

yum install zoo.x86_64 (or rpm -i zoo.x86_64)
linux-17.png

To run the app just execute the package name (generally you can leave off the trailing characters such as "x86_64"), which in this case is zoo:

zoo
linux-19.png

What if you want to remove a package? Let's say Firefox isn't impressing you. You can uninstall it by typing:

yum remove firefox (or rpm -e firefox)
linux-20.png

Note that the DVD won't automatically mount the next time the system boots up (you'd have to type "mount /dev/dvd /mnt/dvdrom" after every reboot, though this can be set up as a permanent mount, which will be discussed in "Mounting devices" in the upcoming Part III ). Therefore, it is recommended to disable the repository once you're done installing packages:

vi /etc/repos.d/rheldvd.repo
 
change “enabled=1” to “enabled=0” (without the quotes)

Save and exit the file via :wq!

To set up a repository of packages from an internet site

To connect to an internet site and use it as a repository, your system must have network and internet access (concepts which you should be familiar with in order to proceed).

This may already be set up if you're working in a test environment using dynamic host control protocol (DHCP) to automatically assign IP addresses. You can confirm this by opening a web browser from the GUI (Firefox is generally installed) and making sure you can get online.

If you need to configure network access manually you can do so from the command line as root using these commands:

Ifconfig eth0 up

This activates the default network interface card, usually known by Linux as "eth0."

Then run:

ifconfig eth0 [IP address you want to use]

ifconfig eth0 netmask [subnet mask you want to use]

route add default gw [default gateway] eth0

This will set the interface IP address, subnet mask and default gateway.

It's also useful to ensure this system has access to a DNS server to look up host names on the internet and translate them to the IP addresses needed for communication.

Type:

vi /etc/resolv.conf

Hit insert to edit the file.

Add the line:

nameserver [your DNS server IP address]

enter :wq! to save and exit the file.

Test the network/internet access before proceeding.

Red Hat requires a subscription manager to use their online repository, which involves setting up an account with Red Hat and registering the system with their site. Details of this process are outside the scope of the article since the goal is to show you how to work with various types of repositories depending on your needs, however it is encouraged that you find out more about these details if you intend to roll out or support Red Hat Linux in a corporate environment.

For testing purposes, you can set up access to a public Linux yum repository on the internet (plenty can be found via Google and this article also provides two examples). This involves creating another .repo file in the /etc/yum.repos.d folder then linking to the public URL of the repository. It's also possible to install the appropriate files directly from the internet to set up a repository.

In the examples below we'll use apt.sw.be and www.elrepo.org.

First you will need to make sure you know what type of CPU you have (32 or 64-bit) in your Linux version.

Type:

cat /etc/*release

Note the results. Now type:

 vi /etc/yum.repos.d/apt.repo

Hit insert, then add this information:

[base]
name=Red Hat Linux $releasever - $basearch - Base
baseurl=http://apt.sw.be/redhat/el6/en/$releasever/$basearch/
enabled=1

[updates]
[base]
name=Red Hat Linux $releasever - $basearch - Base
baseurl=http://apt.sw.be/redhat/el6/en/$releasever/$basearch/

Note $releasever - should be the Red Hat version such as 6.4.

Note $basearch - should be the processor type; i386 for 32-bit and x86_64 for 64-bit.

Save and exit the file via :wq!

If you use a proxy server add the information to yum.conf. Type:

vi /etc/yum.conf

Hit insert, then under the [main] section add:

proxy=http://[proxy server name or IP address]:[port]
proxy_username=[account]
proxy_password=[password]

(The last two lines are only needed if the proxy server requires authentication.)

Save and exit the file via :wq!

(Note that all future references to editing files will involve using the above vi steps to open, edit and save/exit).

Now when you use the yum commands outlined above (start with yum repolist enabled) these should apply to the online repository. As an alternative if you'd like to branch out further, you can add another online repository such as Elrepo.org via a more direct method which lets you import the appropriate yum information directly.

You need to run this command to import the public encryption key (this is recommended for security reasons), and this is a good example of a way to use the rpm command directly against a public file on the internet:

rpm --import https://www.elrepo.org/RPM-GPG-KEY-elrepo.org 

If you use a proxy server add "--httpproxy [proxy server name or IP address] --httpport [proxy server port]" after the rpm command; for instance:

rpm –httpproxy 10.1.1.1 –httpport 8080 –import https://www.elrepo.org/RPM-GPG-KEY-elrepo.org

This command installs the software for Red Hat 5:

rpm -Uvh http://www.elrepo.org/elrepo-release-5-5.el5.elrepo.noarch.rpm 

This command installs the software for Red Hat 6:

rpm -Uvh http://www.elrepo.org/elrepo-release-6-6.el6.elrepo.noarch.rpm

If you have problems with this command try to access the above URLs via a web browser to make sure they are valid. Once these run successfully they will create a file at /etc/yum.repos.d called elrepo.repo, which appears as follows:

### Name: ELRepo.org Community Enterprise Linux Repository for el6
### URL: http://elrepo.org/

[elrepo]
name=ELRepo.org Community Enterprise Linux Repository - el6
baseurl=http://elrepo.org/linux/elrepo/el6/$basearch/
	http://mirrors.coreix.net/elrepo/elrepo/el6/$basearch/
	http://jur-linux.org/download/elrepo/elrepo/el6/$basearch/
	http://repos.lax-noc.com/elrepo/elrepo/el6/$basearch/
	http://mirror.ventraip.net.au/elrepo/elrepo/el6/$basearch/
mirrorlist=http://mirrors.elrepo.org/mirrors-elrepo.el6
enabled=0
gpgcheck=1
gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-elrepo.org
protect=0

[elrepo-testing]
name=ELRepo.org Community Enterprise Linux Testing Repository - el6
baseurl=http://elrepo.org/linux/testing/el6/$basearch/
	http://mirrors.coreix.net/elrepo/testing/el6/$basearch/
	http://jur-linux.org/download/elrepo/testing/el6/$basearch/
	http://repos.lax-noc.com/elrepo/testing/el6/$basearch/
	http://mirror.ventraip.net.au/elrepo/testing/el6/$basearch/
mirrorlist=http://mirrors.elrepo.org/mirrors-elrepo-testing.el6
enabled=0
gpgcheck=1
gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-elrepo.org
protect=0

[elrepo-kernel]
name=ELRepo.org Community Enterprise Linux Kernel Repository - el6
baseurl=http://elrepo.org/linux/kernel/el6/$basearch/
	http://mirrors.coreix.net/elrepo/kernel/el6/$basearch/
	http://jur-linux.org/download/elrepo/kernel/el6/$basearch/
	http://repos.lax-noc.com/elrepo/kernel/el6/$basearch/
	http://mirror.ventraip.net.au/elrepo/kernel/el6/$basearch/
mirrorlist=http://mirrors.elrepo.org/mirrors-elrepo-kernel.el6
enabled=0
gpgcheck=1
gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-elrepo.org
protect=0

[elrepo-extras]
name=ELRepo.org Community Enterprise Linux Extras Repository - el6
baseurl=http://elrepo.org/linux/extras/el6/$basearch/
	http://mirrors.coreix.net/elrepo/extras/el6/$basearch/
	http://jur-linux.org/download/elrepo/extras/el6/$basearch/
	http://repos.lax-noc.com/elrepo/extras/el6/$basearch/
	http://mirror.ventraip.net.au/elrepo/extras/el6/$basearch/
mirrorlist=http://mirrors.elrepo.org/mirrors-elrepo-extras.el6
enabled=0
gpgcheck=1
gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-elrepo.org
protect=0

Here are some further yum commands to use when you have a live repository which may contain updates now or in the future:

linux-article-snip.jpg

It's worth pointing out that once you have your repository set up in yum packages will also be available to install via the GUI (but installed packages likely won't show up in the menus of the GUI, unlike Windows).

For example, in Red Hat Linux 5.2 running the GNOME GUI you would click Applications then choose Add/Remove Software:

linux-22.png

You can browse the packages, grouped under "Desktop Environments," "Applications," "Development," "Servers," "Base System" and "Languages" and add the ones you want by ticking the box to the left and clicking "Apply."

The Package Manager looks different and is accessed in a different way in Red Hat 6.4 running the GNOME GUI; click System then choose Add/Remove Software:

linux-23.png

The interface allows you better access to specific types of packages than in Red Hat 5, but these are installed in a similar fashion.

This provides an elementary introduction into using the basics of yum to handle package management.

Working with startup processes

In Windows, startup processes (these can be scripts, programs or services) are set up via the Services console, the Startup folder or the msconfig command, which lets you control all startup programs.

In Linux, they appear in folders under /etc/rc.d:

linux-24.png

To understand why these subfolders exist we need to discuss the Linux runlevel concept. Basically, the boot process consists of six steps:

  • Reading instructions from the BIOS (basic input output system)
  • Accessing data on the master boot record to find out what steps to take
  • Running a boot loader to start Linux
  • Mounting the root file system and starting up the kernel (the core of the operating system)
  • Executing the initialization phase in which startup processes are run
  • Starting runlevel programs

It's these last two steps which are the key to determine what startup processes will kick off with Linux and they work in conjunction. The runlevel is a sort of operating system state and consists of the following options:

0-halt

1-Single user mode

2-Multiuser without network file systems

3-Full multiuser mode

4-Unused

5-X11 (this is the default; X11 refers to the display manager used to provide a graphical user interface)

6-reboot

These 6 runlevels correspond to the folders shown in the screenshot above; whatever elements are contained in these folders will start when that particular runlevel commences.

You can enter a different runlevel (assuming you have root permissions) at any time by typing:

init [runlevel]

For instance, to enter runlevel 3, full multiuser mode without the GUI, type:

init 3

This will immediately close down the GUI and log you out, presenting a text-only login and interface.

Typing init 6 would immediately reboot the system.

The startup runlevel is set by the /etc/inittab file. In the screenshot below, the "id:5:initdefault:" entry signifies the runlevel for this operating system is 5:

linux-26.png

To change the runlevel you would edit the file as demonstrated in previous examples. Obviously setting it to 0, 4, or 6 would yield problematic results.

Since runlevel 5 is the default for Linux, let's see what that directory contains:

linux-27.png

This folder contains items that are configured to run at start up OR shut down (programs that start with "S" are for startup and programs that start with "K" are for shutdown).

The digits in the programs listed here signify the order in which Linux starts them up. For instance, "S01sysstat" is the first program to be launched while "s99webmin" is the last (this makes sense since it was installed in a prior example).

You can also use the "chkconfig" command in Red Hat Linux to view services. Chkconfig -list will show you which services are set to run for each runlevel:

linux-28.png

As you can see, many here are configured to start during the default runlevel 5.

You can use chkconfig -list "service" to get information about a particular service.

You can use the "service" command to stop and start services if you want to do so temporarily such as to fix a problem or have a change take effect. For instance, service postfix stop and service postfix start will produce the following:

linux-29.png

You could also use service "service" restart if you just wanted to restart it. What if you want to prevent a service from ever starting up again? Simply type:

chkconfig “service” off

This is where "service" represents the name of the service in question. Changed your mind and want that service back? Easy - type:

chkconfig “service” on

You can also set a service to run in a different runlevel by adding the -level [level] switch. For instance, if you want a service to run in runlevel 1 but not 5 use:

chkconfig “service” on –level 1

For multiple runlevels such as 1 and 5:

chkconfig “service” on –level 1,5

To delete a service entirely use chkconfig "service" -del

The /etc/init.d folder contains scripts used for handling existing services. If you had a script you wanted to have execute at boot time you could copy it here; it should be owned by root (use the chown command as shown in Part I) and set it as executable.

To simplify things even further, if you wanted the system to run a single command at startup you could add it to the /etc/init.d/rc.local file which appears similar to the following:

linux-30.png

2. Managing running processes

Now that we've established how to handle startup processes, what about checking for running programs or scripts to see what's happening in the background? With Windows it's easy enough to just hit Ctrl-Alt-Del, choose "Task Manager" then view the Processes tab. With Linux you need the "ps" command.

At first glance, just running ps doesn't seem too insightful:

linux-31.png

However, as is often the case with Linux, the command switches make the difference. Try running this instead:

ps aux
linux-32.png

The above shows much more detailed information, such as the user ID associated with the process, the PID (process identifier; a sort of unique fingerprint corresponding to the process which Windows also uses), the CPU and memory being used by the process, when it was started, the command involved, etc.

All of this data is added by the "aux" switch which provides the following details:

a = show processes for all users

u = display the process user/owner

x = show processes not attached to a terminal (e.g. running from a remote session)

To search for a particular process such as webmin you can use:

ps aux | grep webmin*

("grep" is a search command and the pipe or "|" symbol chains the two commands so that their results are linked)

This shows the following on the test system running webmin:

linux-33.png

It's interesting to note that the command shows both a webmin script running (in this case via Perl) and the search for webmin itself.

There are many more command switches for ps which can be referenced online.

To kill running processes you need the information displayed by ps aux and the kill command. Take note of the PID associated with the process.

Type:

kill [processor identifier]

Let's say you wanted to stop the webmin process, which is using the PID of 21391.

Type:

kill 21391
linux-34.png

In the above screenshot the webmin process has been killed, and ps aux | grep webmin* run once more to confirm that it is gone.

3. Working with user environments

As mentioned before, Red Hat Linux provides an array of graphical user interfaces (GUI) such as GNOME (probably the most popular) and KDE. These constitute as different user environments and can be installed as packages (you can find alternatives via Google, of course, and install them separately depending on your taste).

You can choose which interface to use at logon by clicking Session and then selecting your desired option. You'll be prompted when you proceed as to whether you want to make that session the default for all future sessions if you're choosing something different from the default.

However, there are also specific Linux user environments in the form of profiles, the same as in Windows, which sets a different profile for each user consisting of settings, files, shortcuts, appearances and other unique customization details. Windows keeps these in the c:\users folder (for Windows 7 and more recent releases). The Linux user environments are kept under the /home folder, which has a subfolder corresponding to each user. These are created when users log in for the first time. When users open a terminal window it defaults to their home directory. They can access the home directory at any time using the tilde symbol: ~

For instance, typing cd ~ will take you to the home directory in the shell.

If you type ls -l you will see the contents of the home directory. For example, on Red Hat Linux 6 it will appear as follows:

linux-35.png

This certainly is a close parallel to a Windows profile folder, which contains many similar folders such as Desktop, Documents and Downloads. However, just like in Windows, there's more beneath the surface in the form of hidden files and folders that control greater aspects of the user environment.

Type ls -all to show all files and folders:

linux-36.png

Anything beginning with a period is normally invisible and hidden from display. Many of the hidden directories (directories start with "d") shown here have to do with background details such as the Gnome environment or ssh details.

In order for you to understand how some of the files associated with a user profile work, it's important to discuss shell types.

When you open a terminal window you're actually entering a shell, which is a program that interprets commands. There are many different types of available shells in Linux (and Unix), such as sh (also known as Bourne Shell), csh (also known as C shell, since it resembles the C programming language), and the most common one, bash, or Bourne Again shell.

The bash shell consists of several files which define the profile environment:

linux-snip-2.jpg

Here's what a sample .bash_profile file might look like:

linux-37.png

A good use of the path statement is adding directories from which you want to run executables without having to type the full path name. You can append new paths to the existing ones with a colon; to add /usr/local you would edit the file and change the line as follows:

PATH=$PATH:#HOME/bin:usr/local
linux-snip-3.jpg

Here's what a sample .bashrc file might look like:

linux-38.png

You can take advantage of the functions provided by the .bashrc and /etc/bashrc files to set up aliases, which are command shortcuts. For instance, if you wanted to type "ll" in place of "ls -l" you would edit the file and enter:

alias ll='ls -l'

under the " #User specific aliases and functions" section.

linux-snip-4.jpg

Here's what a sample .bash_history file might look like:

linux-39.png

You can also display these by typing history.

If you want to search the history log for a particular command you can do so using history | grep "command". Additionally, you can clear the history log by typing history -c.

snip-5.jpg

You can add commands to this file which may be useful when exiting a shell. The default contains the command "clear" to clear the screen:

linux-40.png

Profile objects can be copied from user to user as needed, assuming you have sufficient rights. For example, if a user named jsmith has a .bashrc file you want to copy to a user named nbetling, you would type:

cp /home/jsmith/.bashrc /home/nbetling

There are many more uses for user profiles and their contents; this covers the introductory steps to help you get familiar with them.

Part I and Part II of this series has covered the first six sections of the Linux introductory concepts. Part III will conclude the series.

Join Premium Today