Basic Linux Commands
|
Editors: emacs, vi,
pico, jed, vim
Linux Logging in,
Logging Out, and Shutting down
Logging in
Once you have
completed your system install and booted your system, you should see a login
prompt on your monitor. When you did your Linux install you should have set a
root password. You may have also created a user with a password. Therefore to
log in, you will want to type the name of a user or "root" for the
login name and enter the appropriate password. If you logged in as a normal
user and know the root password and want to use administration commands, you
may use the command "su" to become a "super user". Some
systems also support the "sudo" command, which allows
administrative privileges on a command by command basis.
Linux Shell levels and the su command
The command,
"su" will allow a normal user to enter a new shell level as the
root user or as another user if they know the root user's or that user's
password respectively. To become the root user, type "su" then you
will be prompted for the root password. To become another user, type "su
username". You must enter either that user's password to become that
user. Every time you use the su command you enter a new shell level which
means you have invoked a new running copy of the shell program, such as bash.
You can see this change by typing the command "env" and looking at
the value of the environment variable "SHLVL". This value
increments when you use the su command and decrements when you use the
"exit" command to exit that shell environment. You can also see the
shell level value by typing "printenv SHLVL".
Logging out
Use the command
"logout" to exit a given session. If you have logged in, then typed
"su" to become a superuser or another user, you may need to type
"exit" until your SHLVL environment value is 1. Then you can type
"logout" to exit your session. The "exit" command will
take you back to previous shell levels.
Shutting Linux Down
The system is intended
to be shutdown by the system administrator using the shutdown command in one
of the forms shown below. Many systems are set up to capture the
shutdown -h now
shutdown -r +10 "Rebooting in 10 minutes" shutdown -r 13:00 |
The first command will
shutdown and halt the system immediately. The second will reboot the system in
10 minutes and send the message to all users. The third command will shut the
system down and do a reboot at 1:00 in the afternoon
Linux Files and File Permission
Linux files are setup so access to them is
controlled. There are three types of access:
File names and permission characters
File names can be up to 256 characters long with
"-", "_", and "." characters along with letters
and numbers.When a long file listing is done, there are 10 characters that are shown on the left that indicate type and permissions of the file. File permissions are shown according to the following syntax example: drwerwerwe There are a total of 10 characters in this example, as in all Linux files. The first character indicates the type of file, and the next three indicate read, write, and execute permission for each of the three user types, user, group and other. Since there are three types of permission for three users, there are a total of nine permission bits. The table below shows the syntax:
|
- Character
1 is the type of file: - is ordinary, d is directory, l is link.
- Characters
2-4 show owner permissions. Character 2 indicates read permission,
character 3 indicates write permission, and character 4 indicates execute
permission.
- Characters
5-7 show group permissions. Character 5=read, 6=write, 7=execute
- Characters
8-10 show permissions for all other users. Character 8=read, 9=write,
10=execute
- r =
read - This is only found in the read field.
- w =
write - This is only found in the write field.
- x =
execute - This is only found in the execute field.
- s =
setuid - This is only found in the execute field.
- If
there is a "-" in a particular location, there is no permission.
This may be found in any field whether read, write, or execute field.
Examples
Type "ls -l" and a listing like the
following is displayed:
total 10
|
||||||
drwxrwxrwx
|
4
|
george
|
team1
|
122
|
Dec 12 18:02
|
Projects
|
-rw-rw-rw-
|
1
|
george
|
team1
|
1873
|
Aug 23 08:34
|
test
|
-rw-rw-rw-
|
1
|
george
|
team1
|
1234
|
Sep 12 11:13
|
datafile
|
Type and
|
# of
|
Files's
|
File's
|
Size in
|
Date of last
|
Filename
|
Permission field
|
Links
|
Owner
|
Group
|
Bytes
|
modification
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
drwxrwxrwx
|
4
|
george
|
team1
|
122
|
Dec 12 18:02
|
Projects
|
- Type
field: The first character in the field indicates a file type of one of
the following:
- d =
directory
- l =
symbolic link
- s =
socket
- p =
named pipe
- - =
regular file
- c=
character (unbuffered) device file special
- b=block
(buffered) device file special
- Permissions
are explained above.
- Links:
The number of directory entries that refer to the file. In our example,
there are four.
- The
file's owner in our example is George.
- The
group the file belongs to. In our example, the group is team1.
- The
size of the file in bytes
- The
last modification date. If the file is recent, the date and time is shown.
If the file is not in the current year, the year is shown rather than
time.
- The
name of the file.
Set User Identification Attribute
The file permissions bits include an execute
permission bit for file owner, group and other. When the execute bit for the
owner is set to "s" the set user ID bit is set. This causes any
persons or processes that run the file to have access to system resources as
though they are the owner of the file. When the execute bit for the group is
set to "s", the set group ID bit is set and the user running the
program is given access based on access permission for the group the file
belongs to. The following command:
chmod +s myfile
sets the user ID bit on the file
"myfile". The command:
chmod g+s myfile
sets the group ID bit on the file
"myfile". The listing below shows a listing of two files that have the group or user ID bit set.
-rws--x--x 1 root root 14024 Sep 9 1999 chfn
-rwxr-sr-x 1 root mail 12072 Aug 16 1999 lockfileThe files chfn and lockfile are located in the directory "/usr/bin". The "s" takes the place of the normal location of the execute bit in the file listings above. This special permission mode has no meaning unless the file has execute permission set for either the group or other as well. This means that in the case of the lockfile, if the other users (world execute) bit is not set with permission to execute, then the user ID bit set would be meaningless since only that same group could run the program anyhow. In both files, everyone can execute the binary. The first program, when run is executed as though the program is the root user. The second program is run as though the group "mail" is the user's group.
For system security reasons it is not a good idea to set many program's set user or group ID bits any more than necessary, since this can allow an unauthorized user privileges in sensitive system areas. If the program has a flaw that allows the user to break out of the intended use of the program, then the system can be compromised.
Directory Permissions
There are two special bits in the permissions
field of directories. They are: - s -
Set group ID
- t -
Save text attribute (sticky bit) - The user may delete or modify only
those files in the directory that they own or have write permission for.
Save text attribute
The /tmp directory is typically world-writable and
looks like this in a listing: drwxrwxrwt 13 root root 4096 Apr 15 08:05 tmpEveryone can read, write, and access the directory. The "t'' indicates that only the user (and root, of course) that created a file in this directory can delete that file.
To set the sticky bit in a directory, do the following:
chmod +t data
This option should be used carefully. A possible
alternative to this is - Create
a directory in the user's home directory to which he or she can write
temporary files.
- Set
the TMPDIR environment variable using each user's login script.
- Programs
using the tempnam(3) function will look for the TMPDIR variable and use
it, instead of writing to the /tmp directory.
Directory Set Group ID
If the setgid bit on a directory entry is set,
files in that directory will have the group ownership as the directory, instead
of than the group of the user that created the file. This attribute is helpful when several users need access to certain files. If the users work in a directory with the setgid attribute set then any files created in the directory by any of the users will have the permission of the group. For example, the administrator can create a group called spcprj and add the users Kathy and Mark to the group spcprj. The directory spcprjdir can be created with the set GID bit set and Kathy and Mark although in different primary groups can work in the directory and have full access to all files in that directory, but still not be able to access files in each other's primary group.
The following command will set the GID bit on a directory:
chmod g+s spcprjdir
The directory listing of the directory
"spcprjdir":
drwxrwsr-x 2 kathy spcprj 1674 Sep 17 1999 spcprjdir
The "s'' in place of the execute bit in the
group permissions causes all files written to the directory
"spcprjdir" to belong to the group "spcprj" .
Examples
Below are examples of making changes to permissions:
|
|
chmod u+x myfile
|
Gives the user execute
permission on myfile.
|
chmod +x myfile
|
Gives everyone execute
permission on myfile.
|
chmod ugo+x myfile
|
Same as the above command, but
specifically specifies user, group and other.
|
chmod 400 myfile
|
Gives the user read permission,
and removes all other permission. These permissions are specified in octal,
the first char is for the user, second for the group and the third is for
other. The high bit (4) is for read access, the middle bit (2) os for write
access, and the low bit (1) is for execute access.
|
chmod 764 myfile
|
Gives user full access, group
read and write access, and other read access.
|
chmod 751 myfile
|
Gives user full access, group
read and execute permission, and other, execute permission.
|
chmod +s myfile
|
Set the setuid bit.
|
chmod go=rx myfile
|
Remove read and execute
permissions for the group and other.
|
Below are examples of making changes to owner and group:
|
|
chown mark test1
|
Changes the owner of the file
test1 to the user Mark.
|
chgrp mark test1
|
Changes the file test1 to belong
to the group "mark".
|
Umask Settings
The umask command is used to set and determine the
default file creation permissions on the system. It is the octal complement of
the desired file mode for the specific file type. Default permissions are: - 777 -
Executable files
- 666 -
Text files
The permission for the creation of new executable files is calculated by subtracting the umask value from the default permission value for the file type being created. An example for a text file is shown below with a umask value of 022:
666 Default Permission for text file
-022 Minus the umask value
-----
644 Allowed PermissionsTherefore the umask value is an expression of the permissions the user, group and world will not have as a default with regard to reading, writing, or executing the file. The umask value here means the group the file belongs to and users other than the owner will not be able to write to the file. In this case, when a new text file is created it will have a file permission value of 644, which means the owner can read and write the file, but members of the group the file belongs to, and all others can only read the file. A long directory listing of a file with these permissions set is shown below.
-rw-r--r-- 1 root workgrp 14233 Apr 24 10:32 textfile.txtA example command to set the umask is:
umask 022
The most common umask setting is 022. The
/etc/profile script is where the umask command is usually set for all users. Red Hat Linux has a user and group ID creation scheme where there is a group for each user and only that user belongs to that group. If you use this scheme consistently you only need to use 002 for your umask value with normal users.
Linux Directory
Structure
Note: Files are
grouped according to purpose. Ex: commands, data files, documentation.
Parts of a Unix directory tree. See the FSSTND standard (Filesystem standard)
/ Root
|---root The
home directory for the root user
|---home Contains
the user's home directories
|
|----ftp Users include
many services as listed here
|
|----httpd
|
|----samba
|
|----user1
|
|----user2
|---bin Commands
needed during bootup that might be needed by normal users
|---sbin Like
bin but commands are not intended for normal users. Commands run by LINUX.
|---proc This
filesystem is not on a disk. Exists in
the kernels imagination (virtual).
This directory
| | Holds information about
kernel parameters and system configuration.
|
|----1 A directory
with info about process number 1. Each
process
| has
a directory below proc.
|---usr Contains
all commands, libraries, man pages, games and static files for normal
| | operation.
|
|----bin Almost all user
commands. some commands are in /bin or
/usr/local/bin.
|
|----sbin System admin
commands not needed on the root filesystem.
e.g., most server
| | programs.
|
|----include Header files
for the C programming language. Should
be below /user/lib for
| | consistency.
|
|----lib Unchanging data
files for programs and subsystems
|
|----local The place for
locally installed software and other files.
|
|----man Manual pages
|
|----info Info documents
|
|----doc Documentation
for various packages
|
|----tmp
|
|----X11R6 The X windows
system files. There is a directory
similar to usr below this
| | directory.
|
|----X386 Like X11R6 but
for X11 release 5
|---boot Files
used by the bootstrap loader, LILO.
Kernel images are often kept here.
|---lib Shared
libraries needed by the programs on the root filesystem
|
|----modules Loadable kernel
modules, especially those needed to boot the system after
|
disasters.
|---dev Device
files for devices such as disk drives, serial ports, etc.
|---etc Configuration
files specific to the machine.
|
|----skel When a home directory
is created it is initialized with files from this directory
|
|----sysconfig Files that
configure the linux system for networking, keyboard, time, and more.
|---var Contains
files that change for mail, news, printers log files, man pages, temp files
|
|----file
|
|----lib Files that
change while the system is running normally
|
|----local Variable data
for programs installed in /usr/local.
|
|----lock Lock
files. Used by a program to indicate
it is using a particular device or file
|
|----log Log files from
programs such as login and syslog which logs all logins,
| | logouts, and other system
messages.
|
|----run Files that
contain information about the system that is valid until the system is
| | next booted
|
|----spool Directories for
mail, printer spools, news and other spooled work.
|
|----tmp Temporary files
that are large or need to exist for longer than they should in
| | /tmp.
|
|----catman A cache for man
pages that are formatted on demand
|---mnt Mount
points for temporary mounts by the system administrator.
|---tmp Temporary
files. Programs running after bootup
should use /var/tmp.
|
|||
Finding Files in Linux
There are three good
methods of finding files in linux:
The slocate database
To use the locate
command, you will need to have a slocate database set up on your system. On
many systems it is updated periodically by the cron daemon. Try the slocate
command to see if it will work on your system:
locate whereis
Will list all files
that contain the string "whereis". If that command did not work you
will need to run the command:
slocate -u
This command will
build the slocate database which will allow you to use the locate command.
This command will take a few minutes to run.
The whereis command
This command will
locate binary (or executable) programs and their respective man pages. The
command:
whereis linuxconf
will find all binaries
and manpages with the name linuxconf.
|
|||
The find command
The following are
examples of the find command:
find /home -user mark
|
Will find every file
under the directory /home owned by the user mark.
|
|
find /usr -name *spec
|
Will find every file
under the directory /usr ending in ".spec".
|
|
find /var/spool -mtime
+40
|
Will find every file
under the directory /var/spool that has data older than 40 days.
|
Find is a very powerful
program and very useful for finding files with various characteristics. For
more information, read the man page about find by typing "man find".
Locating man pages by subject
There is a keyword
option in the man command that can be used to find man pages that have specific
words in their descriptions. An example is:
man -k process
to find all man pages
that talk about processes. Use the command:
man -k process |grep kernel
to find information on
kernel processes. An equivalent command is the apropos command as follows:
apropos process
The which command
The which(1) program is
a useful command for finding the full path of the executable program that would
be executed if the name of the executable program is entered on the command
line. The command:
which startx
Will show the full path
of the startx command that will be run if "startx" is entered on the
command line when an X session is started.
Linux Help
Sources of help include:
Man Pages
Man pages general are
written to describe programs, configuration files, functions and more areas
of the system. They are organized into numbered sections covering various
subject areas as follows:
|
There may be other non
numbered sections:
- n - New documentation, that may be moved to a more
appropriate section.
- o - Old documentation, that may be kept for a grace
period.
- l - Local documentation referring to this particular
system.
When referenced in
documentation, man pages are many times referred to by section. For example see
the man page on inetd(8). You normally don't need to do anything special to see
the page in section 8 except type "man inetd". The syntax for using
man pages is "man command", where "command" is the name of
the command or item you want help for. Sometimes a given name is in more than
one section. For instance the name crontab is a configuration file and a
utility used to perform configuration. There is a man page for this in sections
1 and 5. If "man crontab" is typed the file in section one will be
shown. In this case you will need to type the section number as follows:
man 5 crontab
Once you are in a man
page, type [space] to see the next page, and type "Q" anytime to quit
Searching pages:
You can use a keyword function in man. To find commands that deal with DNS, type "man -k dns". A list of all commands system calls and other items that have the word "dns" in their name or short description is given. Entering "man -k dns| grep domain" will search the man pages for occurrences of "dns" and "domain". Another command equivalent to using the "man -k is the apropos command. To search on a particular subject in the man page library type "apropos subject". A list of all man pages with the associated subject in its description will be displayed. This information is kept in the apropos database which is updated weekly by cron. See the section on cron or type "man apropos" or "man whatis" for more information.
To print a man page type "man name | lpr -P". You must have your printer set up for this to work.
Searching pages:
You can use a keyword function in man. To find commands that deal with DNS, type "man -k dns". A list of all commands system calls and other items that have the word "dns" in their name or short description is given. Entering "man -k dns| grep domain" will search the man pages for occurrences of "dns" and "domain". Another command equivalent to using the "man -k is the apropos command. To search on a particular subject in the man page library type "apropos subject". A list of all man pages with the associated subject in its description will be displayed. This information is kept in the apropos database which is updated weekly by cron. See the section on cron or type "man apropos" or "man whatis" for more information.
To print a man page type "man name | lpr -P". You must have your printer set up for this to work.
Info Pages
Much documentation is
included as info pages. Many times the same documentation is included in man
pages, but sometimes information is included in infopages that is not in man
pages. I don't like info pages since you need to remember many different key commands
to navigate through them. There is a tutorial in the info pages that you can
use to learn the commands. I recommend that before using info pages, you do at
least a quick tour by taking the tutorial. Take notes and keep them handy when
using the info pages. You may use the info pages by typing "info
command" where command is the name of the command you need information
about. To begin the tutorial, type "info", and look for the help
section. Some of the basic info commands are listed below.
h
|
Take the help tutorial
|
|||
To move down (see more
text) on a screen
|
||||
To page up the screen
|
||||
b
|
To move to the top of
a screen
|
|||
n
|
To move to the next
node (text on a particular topic)
|
|||
p
|
To move to the
previous node
|
|||
d
|
To move to the main
directory node
|
|||
l
|
To move to the last
node you were at. Retraces where you were.
|
|||
Refresh the screen
|
||||
m
|
Show a menu of nodes
you can move to
|
|||
Cancel menu selection
|
||||
name
|
Type node name or
Ctrl-g to cancel after typing "m" for menu
|
|||
u
|
To move back to the
menu you were at. Use this command after making a menu selection to get back
to the last menu from which you made a selection.
|
|||
?
|
Show available
commands.
|
Howto Documents and GNU manuals
Along with the man pages
there is much Linux documentation contained in the various howto files and GNU
documents written by the Linux community. There are many links on the web to
help you find these sources of documentation. The easiest way to find these
documents is to link to the websites that have them in the Linux, Weblinks,
Documentation section of this website. Most of the how to documents should be
on your system in the directory /usr/doc/HOWTO. They are in text format and can
be read by the program "less" or any text editor.
Package Documentation
Linux is generally made
up of many packages. Each package deals with certain functionality of Linux,
but may have several commands. For instance, the etherboot package has a
purpose of allowing users to set up remote machines for booting using a Linux
server. This package has several binary programs used to perform this function.
Most packages contain various text files or html or dvi files that contain
further documentation about the package and their various commands. Most
package documentation is in the directory "/usr/doc" or
"/usr/local" under the specific package name. There are also various
important manuals which may have come with your distribution. These manuals may
be in postscript format. From an X session if you locate these files, you can
double click on them to read them in postscript. The names of some of these
manuals are:
- Bash Reference Manual
- LILO User's Guide
- LILO Technical Overview
- Name Server Operations Guide for BIND
- IP Command Reference
- IPv6 Flow Labels in Linux-2.2
- Tunnels over IP in Linux-2.2
- IP Chains Quick Reference
- Sendmail Installation and Operations Guide
- Sendmail - An Internetwork Mail Router
- mgetty+sendfax
- Automated System Monitoring and Notification with
SWATCH
- SGML-Tools User's Guide
Setting Linux Time
Programs for working with time and date are:
An Example:
While logged in as
root do the following:
"Wed Nov 24, 9:29:17 EST 1999"
date -s 10:10
"Wed Nov 24, 10:10:02 EST 1999"
clock -w
or
setclock
|
The program setclock
will set your hardware clock based on your system configuration parameters
including whether or not your clock is set to universal time.
The "clock -w"
command assumes your hardware clock is set to local time. If it is set for
universal time you will want to type "clock -wu" rather than the
"clock -w" in the line above. If you use the wrong option the time will
be set incorrectly and you will need to do it again.
On a Redhat system, you
can use the program "linuxconf" as root and page down to the next to
the last line in the menu which is "date & time". Select it and
see if the box named "universal format(GMT)", next to "Store
date in CMOS", is checked. If is is not, you may save your time by typing
"clock -w". If it is checked use "clock -wu".
Note: There is a man
page for date that you can use to learn more. Type "man date". You do
not want to make any more changes to time and especially to the date than
necessary, especially while the system is running, since this can trigger the
"cron" daemon to perform various time related system tasks.
An alternate method to set time is.
hwclock --set --date "2/24/2000" If you are using local time
hwclock --set --date "2/24/2000" -utc If you are using universal time
In the rc.sysinit
startup script, this program is used with the options -adjust and -hctosys to
adjust the hardware clock for drift, and set the system time to the hardware
clock at the time of reboot.
On Redhat systems, there
is a configuration program called "timeconfig" which can be used to
configure the system configuration file /etc/sysconfig/clock and
/etc/localtime. This program will use a graphical interface to let the user set
the timezone and whether UTC time is used.
Basic Liinux Devices
The first partition on a
IDE hard drive is called partition 1, and is called /dev/hda1 if the drive is
the primary IDE master.
/dev/fd0
|
Floppy disk
|
/dev/hda1
|
IDE Hard drive 1,
partition 1
|
/dev/hdb3
|
IDE Hard drive 2,
partition 3
|
/dev/sda1
|
First SCSI interface
(probably hard drive), device id 1
|
/dev/sdc3
|
First SCSI interface,
device id 3
|
/dev/cdrom
|
CD ROM drive
|
/dev/mouse
|
Mouse device,
sometimes a pointer to another device such as /dev/psaux, a ps/2 mouse
driver.
|
primary IDE master
|
/dev/hda
|
primary IDE slave
|
/dev/hdb
|
secondary IDE master
|
/dev/hdc
|
secondary IDE slave
|
/dev/hdd
|
The first partition on a
IDE hard drive is called partition 1, and is called /dev/hda1 if the drive is
the primary IDE master.
Linux Tips
Multiple Virtual Terminal access
There are normally 6
virtual terminals in Linux, available by using Alt-F1 through Alt-F6. Each
one can be logged in as a different user. There are normally 6 terminals
available in X also, F7 through F12. The first X session will be on F7 (if on
a local terminal), the second on F8, and so forth. If an X session is started
from F1 and you also have an active session on F2, you can type Ctrl-Alt-F2
to go from the X session to the virtual console on F2. Also to get back to
your X session, you can type Ctrl-Alt-F7. This example assumes that your
terminals are setup in the standard manner with 6 virtual terminals that
spawn the getty program available. You can check your setup by checking your
/etc/inittab file. You should have lines like the following in your file.
1:2345:respawn:/sbin/mingetty tty1
2:2345:respawn:/sbin/mingetty tty2
3:2345:respawn:/sbin/mingetty tty3
4:2345:respawn:/sbin/mingetty tty4
5:2345:respawn:/sbin/mingetty tty5
6:2345:respawn:/sbin/mingetty tty6
See the section on
init for further information on this file.
Linux Command line shortcuts
If typing a command on
the command line, you can press
Pasting text in files
There is a cut and
paste mouse utility that works with virtual consoles called gpm which runs as
a daemon. To use it,
|
Viewing previously displayed text
Text that has scrolled
off the top of the screen may be viewed again using the
key combination. The Keys in the numbers section on
the far right of the keypad do not work for this function, only the grey PgUp
and PgDn keys just to the right of the key. If you want other
keys to perform this function, it would be necessary to map them for bash shell
keymapping. Pressing any other key other than or
will bring you back to the normal screen location.
Accessing Removable
Media
Making a Linux Filesystem on a Floppy
Mounting floppy and CD-ROM drives
Note the CDROM may be
on the secondary controller as a master (/dev/hdc) or slave (/dev/hdd). In
fact, your /dev/cdrom is probably actually a softlink to one of these two
devices, if you have an IDE interface. If you use SCSI, you will probably use
something like /dev/sda1 or 2, etc.
Mounting a parallel port zip drive: mount -t vfat /dev/sda4 /mnt/zipdrive Note: in all these examples, the mount points must exist, be empty, and not already have a device mounted on them. Also you must unmount the device before removing it. |
Setting up Removable and External Filesystems to Automatically
mount when used
- The program "autofs" must be setup to run as
a daemon upon system startup. To do this with Redhat Linux, use the
program "linuxconf" and select "Control", "Control
panel", "Control Service activity". Activate
"autofs" using the menu selections.
- Edit the file "/etc/auto.master" to the
following:
3.
/mnt
/etc/auto.misc --timeout 20
The
above example sets the program to unmount the device after 20 seconds.
- Edit the file "/etc/auto.misc" adding lines
like:
5.
cd -fstype=iso9660,ro :/dev/cdrom
6.
fl -fstype=auto :/dev/fd0
This
will cause the cd-rom to be mounted when you access the directory
"/mnt/cd" and the floppy to be mounted when you access
"/mnt/fl". The directories "/mnt/cd" and "mnt/fl"
must not exist in order for this to work.
- To use automount, put a cd in the CD-ROM drive and type
"ls /mnt/cd" or "cd /mnt/cd".
Making and Managing
Linux Filesystems
Programs used to manage filesystems
Making a Filesystem
Making a swap
partition
|
type "mkswap -c /dev/hda3 10336"
The -c has swap check
for bad blocks. The 10336 is the size of the partition in blocks, about 10M.
The system enables swap partitions at boot time, but if installing a new system
you can type "swapon /dev/hda3" to enable it immediately.
Making an ext2 file
system on a floppy
- fdformat /dev/fd0H1440
- mkfs -t ext2 -c /dev/fd0H1440
Other file systems:
A normal hard drive can have many types of filesystems on it. To create an ext2 file system, type "mke2fs -c /dev/hda2 82080" to create an 82 meg filesystem. Note: mkfs is a front end to many file system types including ext2, minux, and msdos.
A normal hard drive can have many types of filesystems on it. To create an ext2 file system, type "mke2fs -c /dev/hda2 82080" to create an 82 meg filesystem. Note: mkfs is a front end to many file system types including ext2, minux, and msdos.
Checking a Filesystem
fsck - Used to check and
repair a filesystem.
fsck is a front end to a filesystem type specific fsck.ext2, fsck.minix, and fsck.msdos.
Syntax: fsck -t type device
fsck is a front end to a filesystem type specific fsck.ext2, fsck.minix, and fsck.msdos.
Syntax: fsck -t type device
Ex: fsck -t ext2 /dev/hda3
Making a Boot Floppy with a Root Filesystem (not yet complete
or accurate)
To make a Linux boot
floppy with a root floppy will require two floppy disks. One will be used for
the kernel, and the other will hold the root filesystem.
Important functions
needed by an emergency boot filesystem:
e2fsck, mount, tar, gzip, insmod, ftape module for kernel if using tape backups Please note, that it is best to recompile your kernel to do this. This is because most kernel images use modules for support that are stored on your root filesystem and if your root filesystem is corrupt, it may not work properly. The good news is, however, that you will only need a kernel with minimal support, since this is for emergency use only, and you won't need networking support and some other features. The other option is to use a kernel image already compiled that does not depend on modular support if you can find one.
To compile the kernel make sure you provide floppy, CD-ROM and
hard disk support for your types of devices such as IDE or SCSI. In my
compile, I support IDE only. Set CONFIG_BLK_DEV_IDE=Y and all in the IDE
category may be set to Y except for "other IDE chipset support",
CONFIG_IDE_CHIPSETS=N. Ramdisk support (CONFIG_BLK_DEV_RAM=Y) with initial
support. Virtual terminals (CONFIG_VT=Y). CONFIG_VT_CONSOLE=Y,
CONFIG_SERIAL=Y, CONFIG_MOUSE=Y, CONFIG_PS2MOUSE=Y. Under filesystems I
supported all but quota, kernel automounter support, and UMSDOS. Include all
under partition table support. Include VGA text console and Magic SysRq key.
dd if=/vmlinuz of=/dev/fd0
rdev /dev/fd0 /dev/fd0
|
|||||||||||||||||||||||||||||||||||||||
You can type
"env" to see a listing of all current environment variables.
SHLVL indicates how many shells deep the user is. If the level is 2, you must type "exit", then logout to exit. Setting noclobber=1 - keeps files from being clobbered by the shell.
Shell Selection for users
The file
"/etc/shells" lists the valid shells and shell paths on your
system. An example file is:
/bin/bash
/bin/sh
/bin/tcsh
/bin/csh
/bin/ash
/bin/bsh
/bin/bash2
/bin/ksh
/bin/zsh
The command
"chsh" can be used by the user to set his preferred shell. Also the
root user can use this command to set any user's shell. This command with the
-l option will list the available shells. The -s option will allow the user
to change their shell. For example type the following to determine and modify
the user's shell.
The first line will
show available shells, and the second entry will change it. The full path of
the shell must be entered for the command to work.
Startup Scripts
The following scripts
are run by bash if the –noprofile option is not used with the shell:
If bash is invoked as
"sh" it will run only "/etc/profile" and
"$HOME/.profile", above.
The man page says that "$HOME/.bashrc" is run for non-login interactive shells. I'm not sure if it also runs for login interactive shells, but believe it does. If it does, I'm not sure whether it is run after the scripts above, but believe it is.
Key bindings:
If the shell variable "INPUTRC" is
set, probably in "/etc/profile" the keybindings are set by the file
declared in the INPUTRC value. Usually this is "/etc/inputrc".
Otherwise the keybindings are set in the file "$HOME/.inputrc" for
each individual user.
$HOME/.inputrc - User's keybindings definition
/etc/inputrc - Global keybindings definition
Other scripts and
files:
Put any new script
files in /usr/bin or /usr/local/bin. If you put them in /usr/local/bin, they
will be easier to keep track of, but you may want to add /usr/local/bin to
your path environment to make them more accessible. You can put the command
"export PATH=$PATH:/usr/local/bin" in one of the above scripts or
add it to the path statement in /etc/profile.
Therefore to modify
parameters for all users, edit:
To customize user's
setup edit: (Note: In /home/user's name/...)
HOME/.bash_profile - Users environment stuff
and startup programs
$HOME/.bashrc - user aliases and functions $HOME/.bash_logout - User actions to be done at logout $HOME/.inputrc - Contains keybindings and other bits.
The tcsh shell
operates as follows:
/etc/csh.login is run
$HOME/.tcshrc or .cshrc is run $HOME/.login is run
Other files in the
users home directory may be:
.emacs - For the emacs editor. Consists of LISP
functions.
.exrc - For the vi editor .fvwmrc - For the fvwm window manager .twmrc - For the twm window manager .newsrc - For newsreaders. Contains a list of newsgroups offered at this site. .Xdefaults - For programs using the X window system .xinitrc - Shell commands that run when the user logs into an X session. |
|||||||||||||||||||||||||||||||||||||||
Compiling the Kernel
o image=/boot/vmlinuz
o label=rhl
o initrd=/boot/initrd-2.2.14.img
o read-only
o root=/dev/hda2
Read the section about LILO for more information or read the
lilo and lilo.conf man pages.
This step may be necessary
if you are using a kernel previous to the 2.2 series. In the directory
"/usr/include" may be several link files such as "asm",
"linux", and "scsi". These are normally softlinks through
"/usr/src/linux". If they are, you can direct the softlink file
"usr/src/linux" to your new kernel file which may be in the form
"linux-2.2.14". If you don't have the "linux" softlink
file and don't want to create it, you will need to remove and redirect the
softlink files in "/usr/include" to the proper location of your new
kernel source.
The sysctl tool
This tool is worth
mentioning in this section since it is used to manipulate kernel parameters.
If you type "sysctl -a |more" you will see a long list of kernel
parameters. You can use this sysctl program to modify these parameters.
However, I have been unable to add new parameters.
|
|||||||||||||||||||||||||||||||||||||||
No comments:
Post a Comment
Note: Only a member of this blog may post a comment.