Back to Basics: Linux Fundamentals
Articles and Tips:
01 Feb 2006
If you're as comfortable with NetWare services as you are in your favorite old jeans, I've got good (albeit old) news for you: the NetWare services you've grown to know and love are also available on Novell Open Enterprise Server for Linux. The arguably better news is that getting and keeping Open Enterprise Server for Linux up and running is easier than you might think.
This article is the second in a nine-part series designed to help you bridge your NetWare skills to Open Enterprise Server for Linux. Like the Novell training program upon which it is based, this series seeks to demystify the process of deploying and managing Open Enterprise Server for Linux. (See novell.com/training/promotions/netwaretolinux/modules.html.)
Last month's article launched this series with a brief history of Linux, an explanation of open source and a discussion of the Novell-Linux relationship. (See http://support.novell.com/techcenter/articles/nc2006_01b.html.) This article continues to increase your Linux comfort level by introducing these fundamentals:
Understanding runlevels
Logging in and out
Using the Linux desktop
Using the Linux shell
Understanding and viewing processes
Shutting down and restarting the server
Run Linux, Run!
After you power on your server, Linux runs through a seven-step boot process. (See This Boot Was Made for Running.) In the final step, /sbin/init executes the default runlevel for the system.
A runlevel defines a set of running services for a particular system state. For example, the default runlevel for a server is typically runlevel 3, which defines the set of services required for a multi-user system with full network functionality.
Linux offers seven runlevels, which you can switch between without having to shut down or reboot your system:
Shutdown
Single-user login
Multi-user login without network connection
Multi-user login with network connection
Not defined
Multi-user login with network connection and X server
Reboot
In and Out
After your system boots, you'll see a login dialog in either a graphical or command-line interface, depending on how you've configured Novell Linux Desktop.
Included with Open Enterprise Server for Linux, Novell Linux Desktop packs Novell products and services atop your choice of either GNOME or K Desktop Environment (KDE). In this series, you'll read about KDE.
From the KDE graphical login manager, you'll find no surprises. Here you simply type your username and password in the appropriate fields. For example, you might type the root or admin username and enter the appropriate password.
If you prefer, you can quit the graphical login manager and log in using a command-line interface from any one of six virtual (text) consoles. To access a virtual console from the graphical login manager, press Ctrl+Alt+Fx (x represents a number 1 through 6, for example, F1 is the first console, F2 is the second.)
Logging in from a command prompt is straightforward: at the prompt, type in your username, press Enter; type in your password, press Enter again, and voila: a command prompt now awaits your input. You can log in from any one of the consoles and switch between them by pressing Alt+Fx. (To return to the graphical login manager, press Ctrl+Alt+F7.)
To log out from a virtual console, type exit. To log out from the graphical interface, right-click on the desktop and select Logout username from the menu.
Familiar Look and Feel
Like the login dialogs, the desktop should look and feel familiar to you. (See Figure 1.) It has three main components:
control panel, also called the "kicker"
desktop icons
desktop itself
Figure 1: Novell Linux Desktop, included with Open Enterprise Server for Linux, enables you to choose between GNOME and K Desktop Environment. KDE has three main components: the kicker (that runs along the bottom), the desktop icons and the desktop itself.
The Kicker Is . . .
The kicker runs across the bottom of the desktop (See Figure 1) and displays several items (from right to left):
the clock
the system tray, which displays mini programs such as the clipboard
the taskbar, which displays any open applications
numbered buttons that enable you to switch between virtual desktops
various icons, including:
icons you click to open programs such as the Kmail client, the Konqueror browser, and the SUSE HelpCenter
a terminal window, for one-click access to a command prompt
a house icon, for easy access to your Home directory
the Novell icon, to view the KDE Menu (See Figure 2).
Figure 2: You click the Novell button in the kicker to access the KDE Main Menu.
One Click Away From . . .
Several icons are included on the desktop:
Trash
My Computer
Printer
Novell and SUSE Linux icons (to access these Web sites)
YaST (the SUSE Linux administrative utility)
These icons function as you'd expect them to, with maybe one exception: by default, they require only one click to launch their programs and services.
You can add desktop icons by either dragging entries from the KDE Menu to the desktop or right-clicking the desktop and selecting Create New.
The Right-Click Way To . . .
Right-clicking the desktop opens a list of desktop configuration tools and tasks. This list enables you to easily complete tasks, such as creating new files and folders, locking the screen, logging out and cascading or uncluttering windows.
Bourne Again
The default command-line interpreter for Linux is Bash, that is, Bourne Again SHell (named after Bourne, one of the original UNIX shells). Bash is also a programming language used to write scripts that automate tasks.
At the command line, the order you enter operatives is different than you might expect. In Linux, you enter the command, then options or switches, followed by parameters. For example, the command ls -l /etc displays a list of the contents of the /etc directory with added information.
You access the command prompt by logging in to a virtual console or from within the GUI by selecting the terminal program icon from the kicker. (This icon looks like a monitor with a sea shell on it. See Figure 1.)
Bash has several features that make it easier to use, including these:
Command-Completion
From the command prompt, type a few letters of a command or a directory path, and press Tab once (or twice) to complete the command (or path) or get a list of possible commands (or paths).
History
From the command prompt, type history, then use the Up and Down Arrows to view commands in cache.
Use the arrow keys to highlight the command in cache th't you'd like to execute, and press Enter.
Type a few letters and use Page Up and Down to find the commands you've typed that start with those letters.
PS
When a program starts on Linux, the kernel creates a process, and to each process the kernel assigns a Process ID, or PID. Several commands enable you to control the behavior of processes to varying degrees. Logged in as root, you can use these commands to manipulate any process. Other users can manipulate only their own processes.
To view the status of a process, use the ps command, which displays the processes (and their PIDs) connected to your terminal. If you're logged in as root and you want to see all processes connected to a terminal, use the ps a command.
The kill command stops a process (based on its PID) using one of several signals. If you use kill without specifying a signal (for example, kill 1234), the kernel sends the process signal 15, SIGTERM. SIGTERM instructs the process to finish what its doing and then stop; it's a tidy way to stop a process.
When a process is misbehaving and you need it to stop immediately, use signal 9, SIGKILL (kill -9 1234.) SIGKILL can be a little messy (potentially leaving open a file or two), so use it only in cases of emergency. To view a list of all available kill signals, use kill -l.
Various commands enable you to manipulate process priority levels, ranging from the lowest priority, 19, to the highest priority, -20. While it may seem counter intuitive to assign low-priority processes high numbers and high-priority processes low numbers, think of it this way: the higher the number, the nicer the process--and nice processes let other processes go first. (See Figure 3.)
Figure 3: You can set and change process priority levels. Priority levels essentially dictate how nice a process should be. Hence, low priority processes receive high numbers (because they're very nice) and high priority processes receive low numbers (because they're not nice at all).
The nice command enables you to specify just how nice you want a process to be when you start it. By default, nice assigns priority 10. Thus, typing nice prgm starts prgm with a priority of 10. To specify a different priority, type nice, the priority level, then the process (nice -10 prgm). Only root can start processes with a priority higher than -10.
You can run more than one command at a time. If you'd like to enter a new command when a different command is already running, press Ctrl+Z to pause the current command. Next, type bg to run this command in the background. Now you can enter a new command. To move a background command to the foreground, use fg. (See Table 1, Command Cheat Sheet.)
Shutting Down
From the command line, you have several options for shutting down properly: shutdown -h now, halt, and init 0. To reboot, you have an equal number of options: shutdown -r now, reboot, and init 6.
Unlike the Windows world, Linux does not typically recognize Ctrl+Alt+Del as a shut down or reboot option; however, you can configure (or disable) this key combination in /etc/inittab.
Moving On
When you take the training course on which this series is based, you'll be expected to complete several exercises at this piont. Each exercise offers the opportunity to practice the Linux fundamentals about which you've just read, from booting the system to shutting it down. Additionally, you'll be given the opportunity to locate and navigate many Linux help resources. (See Table 2, Help!)
In the next article, you'll learn about the features and installation of Novell Open Enterprise Server for Linux.
Command Cheat Sheet
Use this cheat sheet to get a head start on commonly-used Linux commands.
Command
|
Description
|
ls |
list directory content |
ls |
lists content of current directory |
ls /directoryA |
lists content of directoryA |
ls -l |
lists more information on files |
ls -a |
lists hidden (.*) files too |
ls -R |
lists directories recursively |
ls -i |
lists files' inode numbers |
CD-ROM Drive |
4X CD-ROM drive |
Command
|
Description
|
cd |
change directory |
cd |
changes to home directory |
cd /dirA |
changes to directoryA |
cd - |
changes to the previous working directory |
Command
|
Description
|
cp |
copy file |
cp fileA fileB |
copies fileA to fileB |
cp fileA fileB directoryC |
copies fileA and fileB to directoryC |
cp -a directoryA directoryB |
copies directoryA into directoryB |
cp -a directoryA/. directoryB |
copies files and directories in directoryA to directoryB |
cp -i fileA fileB |
copies fileA to fileB after confirmation |
Command
|
Description
|
mv |
move or rename file |
mv fileA fileB |
renames fileA to fileB |
mv fileA fileB directoryC |
moves fileA and fileB to directoryC |
mv -I fileA fileB |
renames fileA to fileB after confirmation |
Command |
Description |
rm |
remove file or directory |
rm fileA |
removes fileA |
rm -i fileA |
removes fileA after confirmation |
rm -f fileA |
removes fileA without confirmation |
rm -r dirA |
removes directoryA and its content |
Command
|
Description
|
mkdir |
make or create directory |
mkdir dirA |
creates directory dirA |
mkdir -p dirB/subdir/subsubdir |
creates subsubdir and all parent directories if they don't exist |
Command |
Description |
rmdir |
remove directory |
rmdir dirA |
removes dirA if it is empty |
rmdir -r dirA |
removes dirA if it is NOT empty |
Command
|
Description
|
ps |
view process |
ps |
view own processes that are connected to a terminal |
ps a |
view all processes connected to a terminal |
ps aux |
view all processes with owner info |
*Only root can set or change process priority to a level higher than -10.
Command
|
Description
|
top |
view processes in a list updated every few seconds |
ksysguard |
similar to top except with a GUI |
kill |
send signals to processes |
kill -l |
display list of available signals |
kill 1234 |
send signal 15 (SIGTERM) to process 1234 |
kill -9 2345 |
send signal 9 (SIGKILL) to process 2345 |
nice |
start a process with priority value ranging from 19 (low) to -20 |
nice prgm |
starts prgm with priority of 10 |
nice -10 prg |
starts prg with a priority of -10* |
renice |
change priority of a running process (see nice) |
renice 10 99 |
resets priority of process 99 to 10 |
Ctrl+Z |
stops program started in a shell |
bg |
resumes stopped program in background |
prgm & |
starts program in background |
fg |
moves background program to foreground |
jobs |
shows running programs started from this shell |
runlevel |
shows previous and current runlevel |
init [runlevel]5 |
changes runlevel |
shutdown -h now |
shuts down system |
halt |
|
init 0 |
|
shutdown -r now |
reboots system |
reboot |
|
init 6 |
|
Ctrl+Alt+Del |
shuts down or reboots server |
HELP!
Help Resource
|
Description
|
How to Access
|
Navigation Tips and Commands
|
SUSE HelpCenter |
A portal to help resources |
Click life saver icon in the kicker |
Left panel displays help resources |
Right panel displays resource contents |
|||
Manual Pages |
Pages that provide descriptions of Linux commands |
From command prompt, type man command |
Organized in sections |
Program that displays manual pages is less |
From Konqueror browser, type man: command |
From command prompt and Konqueror man 5 shows manual pages from section 5 |
|
man -f lists man pages for string |
|||
man -k lists man pages where string appears in part of the name of the man page |
|||
man ls lists contents of directory |
|||
From command prompt |
|||
Page up/down scrolls half a page |
|||
Space, b scrolls full page |
|||
q quits less |
|||
q quits man pages |
|||
Info Pages |
Pages that provide help information with page navigation |
From command prompt, type info command |
u one level up |
HOW-TOs |
Explanations of tasks (for example, how to configure a DNS server) |
tldp.org |
|
Web sites |
linux.org |
This Boot Was Made for Running
Wonder what happens after you power on your Linux server and before you see the cursor flashing in the username field? Here's the scoop on the Linux boot:
BIOS reads the boot loader from the master boot record
Boot loaders loads the kernel
Kernel loads the initial RAM drive image (initrd)
Kernel executes linuxrc (which initializes hardware and mounts the real file system)
Kernel starts the first process /sbin/init
/sbin/init reads /etc/inittab and executes scripts in /etc/init.d/boot
/sbin/init executes the default runlevel
* Originally published in Novell Connection Magazine
Disclaimer
The origin of this information may be internal or external to Novell. While Novell makes all reasonable efforts to verify this information, Novell does not make explicit or implied claims to its validity.