0% found this document useful (0 votes)
30 views22 pages

Unit 1 Chapter 3

LSA

Uploaded by

krpal204
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PPTX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
30 views22 pages

Unit 1 Chapter 3

LSA

Uploaded by

krpal204
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PPTX, PDF, TXT or read online on Scribd
You are on page 1/ 22

UNIT-1

Chapter-3

System Administration Tasks


Performing Job Management Tasks

FIGURE 3 .1 If you start a job as a background job, its job ID and


PID are displayed.
Performing Job Management Tasks

TABLE 3.1 Managing foreground and background jobs


Managing Jobs

1. From a graphical user interface, open a terminal, and from


that terminal, start the system-config-users program.

2. Click in the terminal where you started system-config-users,


and use the Ctrl+Z key sequence.

3. Use the bg command to move the job you started by entering


the system-configusers command to the background.

4. From the terminal window, type the jobs command. This


shows a list of all jobs that are started from this terminal.

5. put a background job back into the foreground, use the fg


command.
System and Process Monitoring and Management

• TABLE 3. 2 Commands for process management


Command Use

PS Used to show all current processes

Kill Used to send signals to processes, such as asking or


forcing a process to stop
pstree Used to get an overview of all processes, including the
relationship between parent and child processes
killall Used to kill all processes, based on the name of the
process
top Used to get an overview of current system activity
Managing Processes with
ps
The ps command helps you to find out what a specific
process is doing on your server. ps shows information about
the current status of processes.

Two of the most useful ways to use the ps commands are in


the command
• ps afx,
• ps aux
FIGURE 3. 2 Displaying process information using ps aux
When using ps aux, process information is shown in different columns:
USER The name of the user whose identity is used to run the process.

PID The process identification number, which is a unique number that is needed to manage processes.

%CPU The percentage of CPU cycles used by a process.

%MEM The percentage of memory used by a process.

VSZ The virtual memory size. This is the total amount of memory that is claimed by a process. It is common for
processes to claim much more memory than they actually need. This is referred to as memory over allocation.

RSS The resident memory size. This is the total amount of memory that a process is actually using.

TTY If the process is started from a terminal, the device name of the terminal is mentioned in this column.

STAT The current status of the process. The top three most common status indicators are S for sleeping, R for
running, or Z for a process that has entered the zombie state.

START The time that the process started.

TIME The real time in seconds that a process has used CPU cycles since it was started.

COMMAND The name of the command file that was used to start a process. If the name of this file is between brackets, it is
a kernel process.
Sending Signals to Processes with the kill Command

Three signals are available at all times:


• SIGHUP (1)
• SIGKILL (9)
• SIGTERM (15)
Managing Processes with ps and kill
1. Open a terminal window (right-click the graphical desktop and select Open in
Terminal).
2. Use the bash command to start Bash as a subshell in the current terminal
window.
3. Use ssh -X localhost to start ssh as a subshell in the Bash shell you just opened.
4. Type gedit & to start gedit as a background job.
5. Type ps afx to show a listing of all current processes, including the parent-child
relationship between the commands you just entered.
6. Find the PID of the SSH shell you just started.
7. Use kill followed by the PID number you just found to close the ssh shell.
Using top to Show Current System Activity

The top program offers a convenient interface in which you can monitor
current process activity and also perform some basic management tasks.
Figure 3.3 shows what a top window looks like.
FIGURE 3 . 3 Showing current system activity with top
Scheduling Jobs

To start jobs automatically, you can use cron.

cron

cron cron
daemon configuration

cron jobs are started from the directories:


1. /etc/cron.hourly
2. /etc/cron.daily
3. /etc/cron.weekly
4. /etc/cron.monthly
Five different positions are used to specify date
and time. You can use the following time and date
indicators:
Mounting Devices

Example: shows how to mount a USB flash drive.


In this Example, you’ll learn how to mount a USB fl ash drive. After mounting
it successfully on the /mnt directory, you’ll then dismount it. You’ll also see
what happens if there are files currently in use while dismounting the device.
1. Open a terminal, and make sure you have root privileges.
2. Insert a USB flash drive in the USB port of your computer.
3. Use dmesg to find the device name of the USB flash drive.
4. Use fdisk -cul /dev/sdb to find current partitions on the USB flash
drive. I’ll
assume you’ll find one partition with the name of /dev/sdb1.
5. Use mount /dev/sdb1 /mnt to mount the USB flash drive on the /mnt
directory.
6. Use cd /mnt to go into the /mnt directory.
7. Type ls to verify that you see the contents of the USB flash drive.
8. Now use umount /dev/sdb1 to try to dismount the USB flash drive.
This won’t work because you still are in the /mnt directory. You’ll see the
“ device is busy” error message.
9. Use cd without any arguments. This takes your current shell out of
the /mnt directory
and back to your home directory.
10. At this point, you’ll be able to dismount the USB flash drive
successfully using
umount /dev/sdb1
Working with Links

Links is very useful to be able to access a single file from different locations.
A link appears to be a regular file, but it’s more like a pointer that exists in one
location to show you how to get to another location.
In Linux, there are two different types of links:-
• A symbolic link
• A hard link
To create a link, you need the ln command. Use the option -s to create a symbolic
link.
Without this option, you’ll automatically create a hard link. First you’ll put the
name of the original file directly after the ln command. Next you’ll specify the
name of the link you want to create.
Creating Links
1. Open a terminal, and make sure you have root permissions.

2. Use the command ln -s /etc/hosts ~/symhosts. This creates a symbolic link with
the name symhosts in your home directory.

3. Use the command ln /etc/hosts ~/hardhosts. This creates a hard link with the
name hardhosts in your home directory.

4. Use the command echo 10.0.0.10 dummyhost >> /etc/hosts. Verify that you can
see this addition in all three files: /etc/hosts, ~/symhosts, and ~/hardhosts.

5. Use the command ls -il /etc/hosts ~/symhosts ~/hardhosts. The option –I shows
the inode number. You can see that it is the same for /etc/hosts and ~/hardhosts, like
all other properties of the file.

6. Use rm /etc/hosts. Try to read the contents of ~/symhosts. What happens? Now
try to access the contents of ~/hardhosts. Do you see the difference?

7. Restore the original situation by re-creating the /etc/hosts file. You can do that
easily by making a new hard link using ln ~/hardhosts /etc/hosts.
Creating Backups
The tar command is the most common way of
creating and extracting backups on Linux.
Three major tasks are involved in using tar:
1. creating an archive,
2. verifying the contents of an archive, and
3. extracting an archive.

To create an archive of all configuration files in


the /etc directory, for example, you would use tar
cvf /tmp/etc.tar /etc.
Archiving and Extracting with tar
In this exercise, you’ll learn how to archive the contents of the /etc
directory into a tar file. Next you’ll check the contents of the archive, and
as the last step, you’ll extract the archive into the /tmp directory.

1. Open a terminal, and use the following command to write an archive of


the /etc directory to /tmp/etc.tar: tar zxvf /tmp/etc.tar /etc.

2. After a short while, you’ll have a tar archive in the /tmp directory.

3. Use the command file /tmp/etc.tar to verify that it is indeed a tar


archive.

4. Now show the contents of the archive using tar tvf /tmp/etc.tar.

5. Extract the archive in the /tmp directory using tar xvf /tmp/etc.tar.
Once finished, the extracted archive is created in the /tmp directory,
which means you’ll find the directory /tmp/etc. From there, you can
copy the fi les to any location you choose.
Managing Printers
Setting Up System Logging

List ing 3.4 : Part of rsyslog.conf


#### RULES ####
# Log all kernel messages to the console.
# Logging much else clutters up the screen.
#kern.* /dev/console
# Log anything (except mail) of level info or higher.
# Don't log private authentication messages!
*.info;mail.none;authpriv.none;cron.none /var/log/messages
# The authpriv file has restricted access.
authpriv.* /var/log/secure
authpriv.* root
# Log all the mail messages in one place.
mail.* -/var/log/maillog
# Log cron stuff
cron.* /var/log/cron
# Everybody gets emergency messages
*.emerg *
30 fewer lines

You might also like