0% found this document useful (0 votes)
9 views

Basic Linux Training

Uploaded by

azeemrahman.k
Copyright
© © All Rights Reserved
Available Formats
Download as PPT, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
9 views

Basic Linux Training

Uploaded by

azeemrahman.k
Copyright
© © All Rights Reserved
Available Formats
Download as PPT, PDF, TXT or read online on Scribd
You are on page 1/ 86

Basic Linux Training

User Track

Slide 1 January 24, 2025


Index

— Section 1: Linux Overview


— Section 2: Using Commands
— Section 3: The Shell Environment
— Section 4: X Window System Basics
— Section 5: Operating System Basics
— Section 6: Configuration Basics
— Section 7: Mentor Graphics Software Installation

Slide 2 January 24, 2025


Why We’re Here….
To provide basic instruction on use and configuration of
Mentor Graphics software on the Red Hat Linux
Operating System. By the end of the course, you will be
able to:

— Use basic commands for file manipulation


— Customize your shell environment
— Understand basic shell scripting
— Manipulate the X Window System Environment
— Use commands for remote access
— Manipulate the startup and shutdown environment
— Install and configure Mentor Graphics software

Slide 3 January 24, 2025


Section 1: Linux Overview

 Linux is UNIX
 Linux is Multi-user
 Linux uses a hierarchical file system
 Access to the OS through the shell
 Offers a text based command interface

 Usernames and passwords


 The superuser account (root)
 Logging in
 Changing your password

Slide 4 January 24, 2025


Usernames, Passwords, and Logging in

Slide 5 January 24, 2025


Usernames, Passwords, and Logging in

Slide 6 January 24, 2025


Section 2: Using Commands

 Command line syntax


 Finding commands
 Using man
 Basic file manipulation
 Using wildcards
 The vi editor
 DOS utilities
 Lab

Slide 7 January 24, 2025


Command Line Syntax

Slide 8 January 24, 2025


Finding Commands
 Depending on your shell, you could use the built in command
‘which’

 Depending on your OS, you could use the command ‘whereis’

 You can always use ‘find’, which works for pretty much
anything

Slide 9 January 24, 2025


Using man
 Easy to remember
syntax: man command

 ‘whatis’ database helps


to locate man pages for
commands whose name
you can’t remember

 Two ways to access


‘whatis’: ‘apropos’ or
‘man -k’

Slide 10 January 24, 2025


Essential File Manipulation
Commands
 cd - change directory
 ls - list directory contents
 cp - copy
 mv - move
 ln - link
 rm – delete a regular file or symbolic link
 rmdir – delete a directory
 touch - create or update time stamp
 chmod - change permissions
 chown - change ownership
 chgrp – change group ownership
 mkdir - create a directory
 The wildcard character (*)

 The vi editor

Slide 11 January 24, 2025


Slide 12 January 24, 2025
Dos Utilities
Linux has several utilities that help you work with DOS
formatted file systems and text files.

dos2unix – converts a file end of line format


unix2dos – converts it the other way

mtools – a suite of tools that allow you to manipulate MS-


DOS formatted files from your Linux box

mkdosfs – creates an MS-DOS file system on a device

Slide 13 January 24, 2025


Section 1 & 2 Lab
 Login to the system. Your login name is student(n) and your
password is student1
 Change your password
 Locate the passwd program (full path name)
 How does one lock out a user account (don’t actually lock the
account)
— What method did you use to find out?
 Practice the file manipulation commands
— Try using some wildcards

— Create a symbolic link

— Change ownership and group


 Use the vi editor to add the following to your .bashrc file:
— alias cls=‘tput clear’

— source .bashrc

— Try your new alias by typing ‘cls’. What does it do?

Slide 14 January 24, 2025


Section 3: The Shell Environment

 File and directory permissions


 ‘dot’ files
 Search path
 Basic shell scripting
 Environment variables
 Aliases
 Cool features of the shell
— Background and foreground jobs
— File completion
— Redirection and pipes
— Scripting on the fly
— Colorization

Slide 15 January 24, 2025


File and Directory Permissions
In UNIX, the concept of ownership is divided into 3 parts: Owner,
Group, and World. The type of file operations allowed is also
divided into 3 parts: Read, Write, and Execute. An octal value
decides what kind of access is granted to a file, and a UID and GID
decide who owns the file, and what group access is granted.

drwxrwxrwx 5 slate rock 512 Feb 20 2003 mnt/


-r-xr-xr-- 1 barneyb lava 12435 Mar 28 2003 modelsim.ini*
drwx------ 2 fredf rock 512 Sep 1 2000 nsmail/
drwxrwxr-x 2 wilmaf rock 512 Dec 26 2002 pc/
drwxrwxrwx 11 bettyr lava 512 Jan 2 2002 pcb_parts/
drwxr-xr-x 2 fredf rock 512 Sep 4 2002 plot_test/
-rw-r--r-- 1 root other 920 Sep 17 2001 plotcap

Slide 16 January 24, 2025


‘dot’ files
‘dot’ files are used to define the user’s environment. They are called ‘dot’
files because the file names start with ‘.’ Example:

.login, .cshrc, .profile, .bashrc, .rhosts, .bash_profile

Which ones are used depends on the shell.

csh
Note: Some Operating Systems have default cshrc and login files. Each
version puts them in different places. Consult your vendor
documentation.
Startup (in this order): .cshrc (always) and .login (if it's a login shell)
Upon exit: .logout (if it's a login shell)
Other dot files: .history (saves command history)

Slide 17 January 24, 2025


‘dot’ files
tcsh
Startup (in this order): /etc/csh.cshrc (always), /etc/csh.login (login shells), .tcshrc (always),
.cshrc (if no .tcshrc file is present)
Upon exit: .login (login shells), .logout (login shells)
Others: .history (saves command history), .cshdirs (saves directory stack)
sh
Startup (in this order): /etc/profile (login shells), $HOME/.profile (login shells)
Upon exit: Any command or script specified using the command: trap "command" 0
ksh
Startup (in this order): /etc/profile (login shells), $HOME/.profile (login shells), $ENV
(always, if it is set)
Upon exit: Any command or script specified using the command: trap "command" 0
bash
Startup (in this order): /etc/profile (login shells), $HOME/.bash_profile (login shells),
$HOME/.profile (login if no .bash_profile file is present), $HOME/.bashrc (non-login shells),
$ENV
Upon exit: .bash_logout (login shells)

Slide 18 January 24, 2025


Follow Your Path, My Child
Perhaps the most important thing to be found in your environment files is
your search path. This determines where the system will look for
programs when you enter a command. If the command you enter is
not in your search path, you get a ‘command not found’ error. Try this
command:

# chkconfig --list

The chkconfig command is located in /sbin, which is not currently in your


search path. Try this command:

# echo $PATH

This will show you your current search path

Slide 19 January 24, 2025


Follow Your Path, My Child
When you use the bash shell, you get a default path assigned from the
/etc/profile file, which is then appended in your own .bash_profile in
your home directory.

Your .bash_profile is there for you to customize as needed. Add


environment variables, aliases, and path updates as you like.

Note that just because something is not in your path doesn’t mean you
can’t run it, if you know where it is. You could run

# /sbin/chkconfig --list

Without having /sbin in your path.

Slide 20 January 24, 2025


Environment Variables

Environment variables are used as a way to represent a value. They are automatically
exported to all subprocesses of the shell they were created in including shell scripts,
applications and subshells. They are commonly used to pass information such as a
directory location or a flag. Example:

MGC_HOME=/apps/mentor/en2002
NUT_SEC_ATTR_OFF=true

If this were defined in the user’s login shell, then all subsequent shells and
applications could refer to these $VARNAME

Defining Environment Variables

The proper syntax for creating environment variables depends on which shell is
used. In the bash shell the export command is used to create and export an
environment variable.

export VARNAME=value

Slide 21 January 24, 2025


Environment Variables

Traditionally, all capital letters are used for environment variable names. This is simply
convention not a requirement. They are case sensitive, though. Value must be
quoted if it contains spaces or other special characters. Example:

# export MACHINE=”RED HAT LINUX"

defines an environment variable, which is now referred to as $MACHINE, that contains


the value “RED HAT LINUX”
In the c-shell and its derivatives the setenv command is used to define environment
variables.

setenv VARNAME value

Note that no equal sign separates varname and value. Example:

# setenv MACHINE ”RED HAT LINUX"

Slide 22 January 24, 2025


Environment Variables

Use the env command without options to display all environment variables currently
defined.
# env
MACHINE=RED HAT LINUX
...
Once an environment variable is defined, its name can be used in place of its value.
Example:

# echo $MACHINE
RED HAT LINUX

Undefining Environment Variables

To remove an environment variable, the Bourne shell and its derivatives (including
bash) use the unset command.
unset VARNAME
The c-shell and its derivatives use the unsetenv command.
unsetenv VARNAME

Slide 23 January 24, 2025


Environment Variables

Built-in Environment Variables

The shell often uses built-in environment variables. Built-in environment variables
are environment variables that have special meaning to the shell. For example, the
USER environment variable contains your username.

# echo $USER
fredf

Others:

MANPATH, VISUAL, TERM, PRINTER, HOME, SHELL

Slide 24 January 24, 2025


Aliases
Much like environment variables, aliases provide a way to make a
shortcut to a command or series of commands. Once defined, you
can simply enter the alias name to do whatever you’ve created it to
do. Examples:

# Aliases for most frequently used commands


#
alias cls 'tput clear'
alias cp 'cp -i'
alias dir 'ls -gFl'
alias runit '/user/kfoster/bin/my_script'
alias ll 'ls -alpF'
alias mv 'mv -i'
alias psw 'ps -auxww'
alias rm 'rm -i'

Slide 25 January 24, 2025


Cool Features
To name but a few:

 Command history
 Background and foreground jobs
 File completion
 Scripting on the fly
 Colorization

Slide 26 January 24, 2025


Cool Features
Command History

The shell will save a command history, and allow you to refer to
commands by number to run them again. This can save a lot of
typing. Example:

kfoster 105 > history


26 11:17 /usr/openwin/bin/xterm -n ”bedrock" -display 147.34.85.22:0.0 &
27 11:17 cd
28 11:17 ll

If I wanted to run that xterm command again, I could either type it all in, or I could do
a !26

Slide 27 January 24, 2025


Cool Features
Background (bg), Foreground (fg), and ‘jobs’ commands allow one
to use a single shell to run multiple programs that would usually
tie up the shell window. Example:

kfoster 105 > xclock&

This starts xclock in the background, so I can run xclock and then use the shell
window to do something else. Without the ‘&’, I would not be able to use the shell
window until xclock was terminated

If I started xclock in the foreground then changed my mind, I could still put it in the
background by doing a ^z (control z) then the command ‘bg’. Note that I can use
the shell window, and the xclock client will still update the display

If I want to bring the application back into the foreground, I simply enter the command
‘fg %(n)’, where (n) is the job number

Use the command ‘jobs’ to see what’s in the background

Slide 28 January 24, 2025


Cool Features
File completion is another feature that can save you typing.
Instead of entering a long name, use enough characters to
make it unique and then enter <esc><esc>. Example:

kfoster 105 > ls


drwx------ 2 kfoster srvc 4096 Aug 22 08:43 orbit-kfoster/
-rw-rw-r-- 1 kfoster srvc 0 Oct 1 15:45 supercalafragilisticexpaladocious
-r--r--r-- 1 root root 11 Aug 22 08:55 .X0-lock
drwxrwxrwt 2 root root 4096 Aug 22 08:55 .X11-unix/

If I wanted to cat the file ‘supercalafragilisticexpaladocious’, I could either type it out,


or I could type

# cat sup<esc><esc>

Which will then complete the name for me

Slide 29 January 24, 2025


Cool Features

You can use redirection to capture command output, or use a file’s


contents as input to a program. Pipes allow you to ‘daisy chain’
commands together so you can enter several commands on a
single command line to run in succession.

Slide 30 January 24, 2025


Cool Features
Using a pipe symbol ( | ) you can daisy chain commands together,
passing the output of one command as the input to the next.
Example:

# cat /etc/passwd | cut -f1 -d: | sort > /tmp/usernames

# ps -auxww | more

# ps -auxww | grep login

Slide 31 January 24, 2025


Cool Features
Sometimes it is useful to capture the output of a command to a
file, or use a file’s contents as input to a command. You can do
this using the redirection symbols. Example:

# find . -name “*foo*” -print > /tmp/foofiles

#! /bin/sh
while read line
do
cat $line
done < /tmp/foofile
exit 0

Slide 32 January 24, 2025


Cool Features
You can a write script that runs on the command line, without
having to save the script into a file. Useful for one timers.
Example:

kfoster 86 > foreach h ( fred wilma pebbles dino)


? ping $h 1
? end
fred is alive
wilma is alive
pebbles is alive
dino is alive

Slide 33 January 24, 2025


Cool Features
You can use colorization in your shell windows with Linux. These
denote certain attributes of the object (directories, regular files,
executable files, links). Each has it’s own color, and is user
definable. You can also turn this off if you want.

To view the current settings or to make changes, edit the


/etc/DIR_COLORS file. This file sets the default for all users on
the machine. To get customization on a per-user basis, copy this
file to your home directory and rename is .dir_colors.

There is another file called DIR_COLORS.xterm shells. (local or


remote)

Slide 34 January 24, 2025


Essential Commands
 echo
— Useful for sending a message to the screen or to find out the value
of an environment variable

 finger
— Find out information about your current session

Slide 35 January 24, 2025


Essential Commands
ps Reports process status. Useful for finding out what is running on
the system and who is running it.

Linux supports both ‘flavors’ of ps; SYSV and BSD UNIX. So both
these commands will work, and do pretty much the same thing

# ps -ef

# ps aux

My personal favorite on Linux is ‘ps auxww’, which does a process


status with 132 column output so nothing gets truncated

Slide 36 January 24, 2025


Essential Commands
Kill is a command you can use to stop a process. To use kill, you
must have the process id of the thing you want to kill.

Examples:

# kill -1 1
Send a soft reset to process number 1 (the init process) which causes it to reread
its config file (/etc/inittab)

# kill -15 1171


Send a signal to process id 1171 and ask it to try and gracefully shut itself down
(close all open files, etc.) and if that’s possible, then terminate.

# kill -9 1171
Send a signal to process 1171 that basically says “die, you gravy sucking pig!”
Unconditional termination of the process.

Slide 37 January 24, 2025


Essential Commands
The sort command has many useful arguments that allow you to
specify how you want to sort the input.

-k (--key=) option lets you specify which field to sort on

-t (--field_separator) option lets you specify what the field is. By


default, it is a single blank space

# sort /etc/password (a simple sort)


# sort -k3 -t: /etc/passwd (sorts on the 3rd field, with : as the
separator)

Slide 38 January 24, 2025


Essential Commands
The cut command allows you to parse a line of input, and then use
only the parts you are interested in.

-f[list] option lets you specify which fields you want

-d[delim] option lets you specify which character will be the


delimiter by which to determine the fields. By default, it is a
single blank space

# cut -f1 -d: /etc/passwd


# cut -f1,4 -d: /etc/passwd

Slide 39 January 24, 2025


Essential Commands
ping is a basic utility that allows you to query a host to see if it is on the
network or not. Examples:

# ping elvis
returns elvis’s name and IP address if elvis is ‘alive’

# ping -c 4 dino
pings dino 4 times then quits

Slide 40 January 24, 2025


Essential Commands
The grep command allows you to search for a string in a file or
from the standard input. Examples:

# grep hoppy /tmp/flintstones


shows all lines in /tmp/flintstones that contain the string ‘hoppy’

# grep -v hoppy /tmp/flintstones


shows all lines that DO NOT contain hoppy

# grep “Great Gazoo” *


shows all lines in all files that contain the string ‘Great Gazoo’

# grep -l “Great Gazoo” *


shows all the filenames that contain ‘Great Gazoo’, but not the lines themselves

# grep -n “Mr. Slate” /tmp/flintstones


shows any line with ‘Mr. Slate’, and preceeds it with it’s line number in the file

# grep -c “Water Buffaloes” /tmp/flintstones


displays only the count of how many times ‘Water Buffaloes’ appears in the file

Slide 41 January 24, 2025


Essential Commands

 cat lists a file’s contents


 more like cat, but suspends output when page is full
 less same as more, but lets you go backwards
 head lists specified number of lines, starting at the
top
 tail same as head, but from the bottom up
 wc counts things (words, lines, characters)

Slide 42 January 24, 2025


Section 3 Lab 1
 What are environment variables that are currently defined?
 What command would you use to see what $HOME was?
 Add your own custom environment variable from the command
line
— echo your environment variable
— unset your environment variable

 Enter the command ‘which cp’, and record results


— unalias cp
— which cp
— source .bashrc
 What shell are you using?
 Using the text editor, add /sbin to your path

Slide 43 January 24, 2025


Section 3 Lab 2
 Start xclock in your shell window
— Can you enter a new command in the window?
— In the window, enter a ctl-z. How about now?
— Observe the clock. Is it still running? (hands moving)
— Enter the command ‘bg’. Now what happens?
— Enter the command ‘fg’. What happens to the shell?
— Enter the command ctl-z again. Then enter the command ‘jobs’
— Assuming the job number is 1, enter the command ‘kill -15 %1’
 Start another xclock, but this time start it like this:
— xclock&
— What’s different?
— Enter some ctl-c’s in the shell window. What effect does it have on
the clock?
— Enter an ‘fg’, then enter a ctl-c. What happens?

Slide 44 January 24, 2025


Section 3 Lab 3
 Use redirection to capture the output of ‘ls -m /etc’ to a file
— cat this file, and observe the contents
 Use the cut command to display only the 3rd file name from each line of the file
you created
 Can you do this without first saving the output to a file? Try it on the /usr
directory
 What command shows you only the first 5 lines of the file you created?
— How about the last 10?

 How many lines are contained in your file?


— How many words?

 What command would you use to find out if the file named ‘yabbadabbado’ was
in your file?
 Customize the shell color scheme, or turn it off, as you prefer
 Create a new file, with all these Flintstones characters in it, in this order: Fred,
Wilma, Barney, Betty, Pebbles, Bam-Bam, Dino, Hoppy, Mr. Slate, Great Gazoo
— Sort the contents of the file and save it into a new file

Slide 45 January 24, 2025


Basic Shell Scripting
All of the commands you have learned thus far can be embedded
into shell scripts. Shell scripts make it easy to repeat routine
tasks. They support variables, looping, redirection, pipes, etc.
(all the good stuff)

Any time you are faced with a repetitive task, consider writing a
shell script to do the job. Shell scripts are easily portable, and
can be written so that they will run on any UNIX platform.

Slide 46 January 24, 2025


Basic Shell Scripting
#! /bin/sh

# This script sends a reminder about relevant dates (via email) to the user. It reads the file $HOME/special_dates.dat to get
# this information. This script is usually set up as a cron job, so you can get the reminder the morning of the special day.
#
# The data in the special_dates.dat file can be set up to remind once a year, once a month, or on a particular day of the week.

MYPATH="/user/kfoster"
MYNAME="[email protected]"

day_of_wk=`date '+%a'`
day_of_month=`date '+%d'`
month=`date '+%h'`

exec < $MYPATH/special_dates.dat

while read line


do
set $line

if [ "$day_of_wk" = "Mon" ] && [ "$1" = "$month" ]


then
echo "$line" >> /tmp/log_$$_spc.dates

elif [ "$1" = "$month" ] && [ "$2" = "$day_of_month" ]


then
echo "$line" >> /tmp/log_$$_spc.dates
fi

if [ "$1" = "$day_of_wk" ]
then
echo "$line" >> /tmp/log_$$_spc.dates
fi

done

Slide 47 January 24, 2025


Basic Shell Scripting
Complete shell scripting instruction is beyond the scope of this course, but
here are some of the basics:

A shell script normally starts with a header line:


#! /bin/sh (or csh, ksh, bash, etc.)

This line gives you an indication of what commands and syntax is supported when you run the
script.

The shell that the script runs does not necessarily have to match the shell that you invoke it
from.

For the most part, shell scripts are pretty linear. They do however, support functions.

sh is the Bourne shell, csh is the C shell, ksh is the Korn shell, and bash is…. Well it’s the
Bourne Again shell.

Slide 48 January 24, 2025


Section 3 Lab 4
(optional)

Write a script that gathers information and produces the following


output:

Your hostname is: hostname


Your hostid is: macaddr
Your Linux version is: version
Your MGC_HOME is set to: $MGC_HOME

Slide 49 January 24, 2025


Section 4: X Window System Basics
The X Window system provides a graphical user interface

 Any host running X can be considered an X server


 The X server is transparent to the user, what you see on the screen are
X clients
 X clients can be displayed on the local server, or remotely on another X
server. To display remotely, you need to set the display variable, and
you need permission
 You have your choice of Window Managers. Window Managers
determine the look and feel of the desktop.
 With Linux, you can have multiple X window sessions from multiple
client machines
 If you want to run the desktop on a foreign host, you need to start the
xdm service (X Display Manager) or one of the other Display Manager
services (kdm, gdm)

Slide 50 January 24, 2025


X Window System Basics
Ownership and Security

An X server is ‘owned’ by the user who starts the X session. Any user,
including root on the same host, must be granted permissions to
display a client

You can enforce greater security by using an access control list

Remote display of X clients

If a X host has only one display, then you can usually connect to the X
server by using the display variable ‘hostname:0’ Example:

# xterm -display dino:0

Slide 51 January 24, 2025


Starting X Windows
Starting the X Window System

Depending on how the installation was done, the X Window System should
already be started. If not, you can start it up with the following
command (after you login)

# startx

If you selected a non-graphical interface when you installed (but you did
install the X windows software) then the system comes up in run level
3 (text interface)

Slide 52 January 24, 2025


Run Levels
Run levels

The /etc/inittab file is where you define the default run level.

The second field of this line is where the default run level is set. In this
case, it defaults to a graphical interface. I strongly recommend this, as
it is very simple to go back to the text based interface. The graphical
interface makes using tools like VNC much nicer.

id:5:initdefault:

Slide 53 January 24, 2025


Changing Modes

If you’ve started the system in graphical mode but want to get back text
mode, do a ‘alt-ctl-f3’ to get back to text mode.

Do ‘alt-ctl-f7’ to get back to graphical mode

Slide 54 January 24, 2025


KDM
The following entry in /etc/inittab is what starts up the graphical login
environment:

# Run xdm in runlevel 5


# xdm is now a separate service
x:5:respawn:/etc/X11/prefdm -nodaemon

The config files for the environment are numerous, and can be found in
/etc/kde/kdm. Actually, these are for the most part links to the files in
the /etc/X11/xdm directory.

Slide 55 January 24, 2025


KDM
If you chose to use KDE as your desktop, then the system is configured with the
kdm (KDE Display Manager) by default. This means that when the system starts
up in X11 mode, you will get a graphical login box and the ability to choose a
window manager. This is all you need if you want to run the desktop only from
the console.

If you want to use a broadcast service like xdmcp on a client machine to run the
desktop on a foreign host, you have to modify the /etc/kde/kdm/kdmrc file and
uncomment the Enable entry under [Xdmcp]. If you don’t you will not see this
machine in your XDM Chooser

[Xdmcp]
# Whether KDM should listen to XDMCP requests. Default is true.
Enable=true

Depending on your network configuration, you also need to modify the


/etc/X11/xdm/Xaccess file and uncomment the line that grants access for any
host to get a login window:
* #any host can get a login window

Slide 56 January 24, 2025


Xconfigurator
If you find that you need to reconfigure the X display attributes (screen
resolution, color depth, refresh rate, mouse buttons) you can do it with
the command ‘Xconfigurator’.

When you run this, it presents a text based configuration tool. I


recommend you drop into text mode first before you run it.

Slide 57 January 24, 2025


Adding Fonts
There are two ways you can add fonts to the font path. You can use the
xset command, or you can modify the /etc/X11/fs/config file.

# xset fp+ /your new font path


Adds your new font path at the end

# xset +fp /your new font path


Adds your new font path at the beginning

If you add your new font path to the catalogue section of the configuration
file, you must restart the font server

# service xfs restart

Slide 58 January 24, 2025


Enable/Disable Font Server

To enable or disable the font server, go to /etc/init.d/xfs and modify the


chkconfig line, making ‘2345’ (to enable) or a ‘-’ (to disable).

#!/bin/sh
#
# xfs: Starts the X Font Server
#
# Version: @(#) /etc/init.d/xfs 2.0
#
# chkconfig: 2345 90 10

Then, do a chkconfig xfs reset

Slide 59 January 24, 2025


Using a Remote Display
To run Mentor applications on a remote display (such as a PC running an
X Windows software or another Linux box) You will have to deal with
font issues. The X server must have access to the fonts either through
a font server or a local directory.

We typically recommend customers collect the fonts, bring them over to


the machine where you want to display the tools, compile them, then
add them to the font path.

Use the same basic process for Xvision, Exceed, etc. The specific process
for each is not covered in this class (Primus records on these subjects
abound)

Slide 60 January 24, 2025


Using a Remote Display
The most common way to use a remote display is to start an Xterm
window on a remote host and send the display back to your machine.

# xterm –display mymachine:0

Or, if you rlogin to the remote host first, you can

# export DISPLAY=mymachine:0
# $MGC_HOME/bin/dmgr&

Remember the X server process is owned by the user who started the
session. In some cases, you may have to grant permissions for a
remote machine to connect to your X display. You do this with the
xhost command as the user who owns the display

Slide 61 January 24, 2025


Creating Desktop Icons
If you frequently access the CD-ROM or floppy drives, you may want to
add shortcut icons to your desktop.

1) Right click on the desktop, go to the ‘Create New’ menu, and select
either CD/DVD ROM device or Floppy Device
2) In the General tab, enter the desired name in the dialog box (eg
floppy, CDROM, /dev/fd0)
3) In the Device tab, select the appropriate device from the drop down
box.
4) Select OK. The device icon appears on the desktop.

Slide 62 January 24, 2025


Section 4 Lab
Use Xconfigurator to change your display properties to match your preference

Add mgc fonts from a Solaris machine to your font path, so you can use your Linux
machine as an X terminal to run the Sun version of the tools.

Experiment with going between text and graphics modes

Experiment with kde and gnome. Poke around in the menus, run commands, etc.

Create desktop icons for your floppy and CDROM in the Window Manager of your
choice

Your machine has 8 unique user accounts on it (student1 – student8; password


‘student1’ for all of them). The first time you login on each account, you get to
select different look and feel. Login on each, and select different options each
time (optional)

Slide 63 January 24, 2025


Section 5: Operating System Basics
Here are some more essential commands:

 file
 tar
 zip, unzip
 gzip, gunzip
 compress, uncompress
 top
 The system log file (/var/log/messages)
 Verifying installed software
 Getting the OS version

Slide 64 January 24, 2025


Process Monitoring (top)

top allows you to monitor processes, determine what is running, who owns it, how much cpu
and memory the process is consuming, and how much memory and swap are available.
Example:

3:56pm up 54 days, 7:01, 9 users, load average: 0.00, 0.00, 0.00


123 processes: 122 sleeping, 1 running, 0 zombie, 0 stopped
CPU states: 0.1% user, 2.1% system, 0.0% nice, 97.6% idle
Mem: 384476K av, 380592K used, 3884K free, 148K shrd, 69288K buff
Swap: 1052248K av, 5760K used, 1046488K free 91744K cached

PID USER PRI NI SIZE RSS SHARE STAT %CPU %MEM TIME COMMAND
4078 root 17 0 1196 1196 928 R 2.3 0.3 0:01 top
1 root 8 0 468 468 400 S 0.0 0.1 0:04 init
2 root 9 0 0 0 0 SW 0.0 0.0 0:00 keventd
3 root 9 0 0 0 0 SW 0.0 0.0 0:00 kapm-idled
4 root 19 19 0 0 0 SWN 0.0 0.0 0:00 ksoftirqd_CPU0
5 root 9 0 0 0 0 SW 0.0 0.0 0:00 kswapd
6 root 9 0 0 0 0 SW 0.0 0.0 0:00 kreclaimd
7 root 9 0 0 0 0 SW 0.0 0.0 0:00 bdflush
8 root 9 0 0 0 0 SW 0.0 0.0 0:01 kupdated

Slide 65 January 24, 2025


Log Files

There are a number of system log files in /var/log.

boot.log - records last time system was shut down, and booted up
cron - records the cron activity
maillog - records sendmail activity
messages - The main system log file, records all system messages
rpmpkgs - Records all the rpms that have been installed
lastlog - keeps track of who logged in, when and from where (requires the
lastlog program to read)
secure - records results of login attempts
XFree86 - records information about the X server

Slide 66 January 24, 2025


Startup and Shutdown

Startup and Shutdown

 The init process


 RC scripts
— S scripts

— K scripts

— Run levels

 Shutting down the system or changing the run levels

 Installing a service for automatic startup and shutdown


— /sbin/chkconfig

Slide 67 January 24, 2025


Startup and Shutdown
Startup and Shutdown

When the system starts up, a series of RC scripts are automatically run.
These scripts live in the /etc/rc.d/* directories. The directory number
corresponds to the run level that the script is invoked in. There are 2
kinds of scripts: S scripts and K scripts. S stands for ‘start’, which
means the script is run when the system starts up. The S is followed by
a number, which determines its start order in relation to the other
scripts. K scripts (K is for kill) work the same way, except they are only
invoked when the system is shut down.

Slide 68 January 24, 2025


Startup and Shutdown
Shutting down the system or changing the run levels

There are lots of ways to shut down the system:


shutdown -r now (shutdown and reboot the system immediately)
shutdown -h now (halt the system immediately)
shutdown -r +5 (shutdown and reboot in 5 minutes)
shutdown -r 21:00 (shutdown and reboot at 11:00 pm)
type ‘reboot’
If enabled, the three fingered salute

If you don’t want to shut all the way down, you can easily move between
run levels (if you are root) with the init command.

Slide 69 January 24, 2025


Verify Installed Software
RPM is an acronym for Red Hat Package Manager. Packages in this format can be
installed, removed, verified, and listed using the rpm tools that come with Linux.
This tool has a command line interface, but there is also a graphical front end.
We will focus mainly on the command line interface. Examples:

# rpm -qa
lists all installed packages

# rpm -qi <package_name>


detailed package information

# rpm -qR <package_name>


lists package dependencies

# rpm -ql <package_name>


lists all files contained in a package

Slide 70 January 24, 2025


Getting the OS Version
There are several ways to do it, depending on what you want to see. When we ask a
customer ‘what version do you have’ we typically expect a response like ‘Red
Hat version 7.3’. Other times, we’re interested in the kernel version. We might
also want to know what gcc version they have, so we can evaluate run time
compatibility.

# cat /etc/issue | head –n 1


Red Hat Linux release 7.2 (Enigma)

# uname –a
Linux driver 2.4.7-10 #1 Thu Sep 6 17:27:27 EDT 2001 i686 unknown

# dmesg | head –n 1
Linux version 2.4.7-10 ([email protected]) (gcc version 2.96
20000731 (Red Hat Linux 7.1 2.96-98)) #1 Thu Sep 6 17:27:27 EDT 2001

Slide 71 January 24, 2025


Lab 5

 What package does the command ‘mcopy’ come from? What version of the
Netscape package is installed on your system?
 Create a tar file that contains the contents of the /var/run directory
— Compress the file

— create a new sub directory in /tmp

— move your tar file in there

— uncompress it

— list the contents of the tar file

— untar it

— remove your sub directory

 Run the top command, wait 20 seconds, and determine the following:
— What process is currently using the most resources?

— How much swap space is currently available?

— How much physical memory is currently available?

Slide 72 January 24, 2025


Section 6: Configuration Basics
Linux has tools that you can use to access a remote computer, do remote
file operations or run commands

 rlogin
 rsh
 rcp
 Files that effect remote access
 ssh

Slide 73 January 24, 2025


rlogin
rlogin starts a terminal session on a remote host. This is the most
common way for you to access a host remotely with a command line
interface. Example:

# rlogin bedrock
Start a remote terminal on the host bedrock

# rlogin bedrock -l root


Start a remote terminal on the host bedrock as the root user

Slide 74 January 24, 2025


rsh
rsh gives you a way to run a command on a remote host

# rsh quarry cat /etc/hosts


Run the command ‘cat /etc/hosts’ on the host quarry

# rsh -l bettyr quarry cat /etc/hosts


Run the command ‘cat /etc/hosts’ on the host quarry as the user
bettyr

Slide 75 January 24, 2025


rcp
rcp allows you to remote copy files from one host to another

# rcp dino:/etc/hosts .
Copies the /etc/hosts file on dino to the current directory

# rcp -r dino:/tmp/bedrock .
Copies the bedrock directory (and all files within it) on dino to the
current directory

Adding a -p argument will attempt to preserve the file attributes

Slide 76 January 24, 2025


Important Files
These files can effect the behavior of the remote tools:

 /etc/hosts.equiv
 $HOME/.rhosts

Slide 77 January 24, 2025


Configuring Remote Access
Example /etc/hosts.equiv

# Allow access for the following hosts


bedrock
flintstone
rubble

#Allow any user from hosts with +, disallow those with -


+flintstone
-rubble

#Allow any user from any host


+

Slide 78 January 24, 2025


Configuring Remote Access
ssh (SSH client) is a program for logging into a remote machine and for
executing commands on a remote machine. It is intended to replace rlogin, rcp
and rsh. It provides secure encrypted communications between two
untrusted hosts over an insecure network. Examples:

# ssh bedrock
Start a login shell on bedrock

# ssh -l bambam bedrock


Start a login shell as bambam on bedrock

# ssh pebbles@bedrock cat /etc/hosts


Run the command ‘cat /etc/hosts’ on bedrock, as the user pebbles

# ssh -f bedrock cat /etc/hosts


Same as above, assumes user is the current user

# scp bedrock:/etc/hosts .
Remote copies the /etc/hosts file from bedrock to the current directory

Slide 79 January 24, 2025


Configuring NFS
Mounting a file system

Once a file system is shared, there are three ways a client might mount it.

1) mount command

2) entry in /etc/fstab

3) automount

In the first two cases, a mount point must be manually created. You do
not need to configure anything in most cases to be a simple NFS client.
The service netfs is enabled by default.

Slide 80 January 24, 2025


Configuring NFS
Mounting a file system

You can setup an entry in your /etc/fstab file to mount a file system at
boot time. Example:

bedrock:/freds_disk /mnt/bedrock nfs defaults 00

This means at boot time, mount the file system /freds_disk that is being
exported by the machine bedrock, on the mount point /mnt/bedrock,
file system type is nfs, use the default options and don’t do any file
system checks on it.

Slide 81 January 24, 2025


Configuring NFS
Mounting a file system

If I enter the mount command, I can see what is currently mounted:

[root@quarry etc]# mount


/dev/hda1 on / type ext3 (rw)
none on /proc type proc (rw)
usbdevfs on /proc/bus/usb type usbdevfs (rw)
none on /dev/pts type devpts (rw,gid=5,mode=620)
none on /dev/shm type tmpfs (rw)
automount(pid909) on /user type autofs (rw,fd=5,pgrp=909,minproto=2,maxproto=3)
greatgazoo:/home/fredf on /user/fredf type nfs
(rw,hard,intr,noquota,rsize=8192,wsize=8192,addr=147.34.58.5)
bedrock:/tmp on /mnt/bedrock type nfs (rw,addr=147.34.58.107)

Slide 82 January 24, 2025


Configuring NFS
Unmounting a file system

When I ran the mount command, I saw this:

bedrock:/tmp on /mnt/bedrock type nfs (rw,addr=147.34.58.107)

I can unmount this file system with either command:

# umount /mnt/bedrock
# umount bedrock:/tmp

Slide 83 January 24, 2025


Enable/Disable Hyperthreading
Disable Hyperthreading

With hyperthreading, Intel effectively replicates many of the internal components of the
Pentium 4 micro architecture, creating a virtual image of a second processor running within
the same silicon. Through a clever manipulation of the CPU's internal "architecture state"
(the contents of various control registers and external interfaces), a hyperthreading CPU
can execute two unrelated code paths in parallel, with instructions from each path vying for
resources in a shared execution core.
Of course, there isn't really a second CPU; it just looks that way to the operating system. In
fact, the illusion is so complete that when you first power up a hyperthreading-enabled
system, the BIOS POST (Power-On Self Test) reports the total number of virtual (as opposed
to physical) processors. And as goes the BIOS, so does the operating system.

The cleanest way to disable hyperthreading is in the system bios. Not all systems have an
option to turn this off. If the option isn’t there, you can try to update the bios.

The other method is to modify the boot parameters.

Slide 84 January 24, 2025


Enable/Disable Hyperthreading
Enabling Hyperthreading

Given an HT-enabled hardware configuration, use the following steps to enable HT in a 2.4 kernel:

1. First, confirm that your kernel is version 2.4.18 or later, with SMP support. There are many ways to do
this, the easiest is to execute the "uname -a" command in a shell. For Red Hat users, Red Hat 7.3 was the
first distribution release to support HT, incorporating a 2.4.18 kernel. If you are using another distribution,
check the kernel version before attempting to use HT.

2. Next, modify your bootloader (grub or lilo), adding the following parameter to any other boot parameters
currently necessary for your system:
acpismp=force

It would be wise to add this as a different boot configuration so that you can boot HT or non-HT. (To create an
explicitly non-HT configuration, add the 'noht' boot flag.)

3. Finally, reboot the system. Before it restarts, enter the BIOS setup program. Under the processor options you
will be able to enable or disable HT. Enable HT, and boot to the 2.4.18 or later SMP kernel with the
additional parameters.

Once you have successfully booted the HT configuration, run top. If HT is properly configured, you should see
twice as many CPU states as you have physical processors (two virtual CPUs per physical cpu)

Slide 85 January 24, 2025


Lab 6
Pick a partner, and experiment with remote access operations (rlogin, rsh,
ssh) to each other’s machines. Configure the system so you can rlogin
without having to enter a password.

Discover what file systems are available on other machines in the class
room, and practice NFS mounting and unmounting a few of them

Configure your machine so that Hyper threading is disabled

Slide 86 January 24, 2025

You might also like