halt
This command shuts down the operating
system, but can only be run by the root user.
#halt
reboot
This command shuts down and restarts
the operating system. It also can only be run by root.
#reboot [will perform simple reboot]
#reboot
-f [will perform fast reboot ]
init 0
This command also shuts down the
operating system, and can only be run by root.
#init 0
init 6
This command restart the operating
system. It also can only be run by root.
#init 6
man
This command opens the manual page for
the command or utility specified. The man utility is a very useful tool. If you
are unsure how to use any command, use man to access its manual page. For
example, you could enter man ls at the shell prompt to learn how to
use the ls utility.
#man ls
info
The info utility also displays a help
page for the indicated command or utility. The information displayed with info
command will be in-depth than that displayed in the man page for the same
command.
info ls
su
This command switches the current user
to a new user account. For example, if you’re logged in as vickey and
need to change to user account to vinita, you can enter su vinita at
the shell prompt. This command is most frequently used to switch to the superuser
root account.
In fact, if you don’t supply a username, this utility assumes that you want to change to the root account. If you enter su -, then you will switch to the root user account and have all of root’s environment variables applied.
This command require password of the user you want switch.
In fact, if you don’t supply a username, this utility assumes that you want to change to the root account. If you enter su -, then you will switch to the root user account and have all of root’s environment variables applied.
This command require password of the user you want switch.
Looking for Files
There are two basic commands used for
file searches: find and locate
find
The find command searches through
directories and subdirectories for a desired file. For example, if you wanted
to find the directory with the grub.conf linux boot loader file, you
could use the following command, which would start the search in the top-level
root (/) directory:
# find /
-name grub.conf
But this search took several minutes
to get it task done. Alternatively, if you know that this file is located in
the /etc subdirectory tree, or /boot/grub/grub.conf you could start in that
directory with the following command:
# find /etc
-name grub.conf
locate
If this is all too time-consuming,
RHEL 5 includes a default database of all files and directories. Searches with
the locate command are almost instantaneous. And locate searches don't require
the full file name. The drawback is that the locate command database is
normally updated only once each day, as documented in the
/etc/cron.daily/mlocate.cron script.
Getting into the Files
Now that you see how to find and get
around different files, it's time to start reading, copying, and moving the
files around. Most Linux configuration files are text files. Linux editors are
text editors. Linux commands are designed to read text files. If in doubt, you
can check the file types in the current directory with the
file * command.
file * command.
cat
The most basic command for reading
files is cat. The cat filename command scrolls the text within the
filename file. It also works with multiple file names; it concatenates the file
names that you might list as one continuous output to your screen. You can
redirect the output to the file name of your choice.
more and less
Larger files demand a command that can
help you scroll through the file text at your leisure. Linux has two of these
commands:
more and less.
With the more filename command, you can scroll through the text of a file, from start to finish, one screen at a time. With the less filename command, you can scroll in both directions through the same text with the PAGE UP and PAGE DOWN keys. Both commands support vi-style searches.
more and less.
With the more filename command, you can scroll through the text of a file, from start to finish, one screen at a time. With the less filename command, you can scroll in both directions through the same text with the PAGE UP and PAGE DOWN keys. Both commands support vi-style searches.
head and tail
The head and tail commands are
separate commands that work in essentially the same way. By default, the head
filename command looks at the first 10 lines of a file; the tail filename
command looks at the last 10 lines of a file. You can specify the
number of lines shown with the -nx switch. Just remember to avoid the
space when specifying the number of lines; for example, the
# tail -n15
/etc/passwd
command lists the last 15 lines of the /etc/passwd file.
cp
The cp (copy) command allows you to
take the contents of one file and place a copy with the same or different name
in the directory of your choice. For example, the cp file1 file2 command takes
the contents of file1 and saves the contents in file2. One of the dangers of cp
is that it can easily overwrite files in different directories, without
prompting you to make sure that's what you really wanted to do.
mv
While you can't rename a file in
Linux, you can move it. The mv command essentially puts a different label on a
file. For example, the mv file1 file2 command changes the name of file1 to
file2. Unless you're moving the file to a different partition, everything about
the file, including the inode number, remains the same.
ln
You can create a linked file.
linked files are common with device files such as /dev/dvdwriter and /dev/par0. They're also useful for making sure that multiple users have a copy of the same file in their directories. Hard links include a copy of the file. As long as the hard link is made within the same partition, the inode numbers are identical. You could delete a hard-linked file in one directory, and it would still exist in the other directory. For example, the following command creates a hard link from the actual Samba configuration file to smb.conf in the local directory:
linked files are common with device files such as /dev/dvdwriter and /dev/par0. They're also useful for making sure that multiple users have a copy of the same file in their directories. Hard links include a copy of the file. As long as the hard link is made within the same partition, the inode numbers are identical. You could delete a hard-linked file in one directory, and it would still exist in the other directory. For example, the following command creates a hard link from the actual Samba configuration file to smb.conf in the local directory:
# ln
smb.conf /etc/samba/smb.conf
On the other hand, a soft link serves
as a redirect; when you open up a file created with a soft link, you're
directed to the original file. If you delete the original file, the file is lost.
While the soft link is still there, it has nowhere to go. The following command
is an example of how you can create a soft link:
# ln -s
smb.conf /etc/samba/smb.conf