#halt
This command shuts down the operating system, but can only be run by the root user.
#reboot
This command shuts down and restarts the operating system. It also can only be run by root.
#init 0
This command also shuts down the operating system, and can only be run by your root user.
#init 6
This command also shuts down and restarts the operating system. It also can only be run by root
#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
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.
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:
The egrep command is more forgiving; it allows you to use some unusual characters in your search, including +, ?, |, (, and). While it's possible to set up grep to search for these characters with the help of the backslash, the command can be awkward to use.
# sed 's/Windows/Linux/' data > newdata However, this may not be enough. If a line contains more than one instance of Windows, the above sed command does not change the second instance of that word. But you can make it change every appearance of Windows by adding a "global" suffix:
# sed 's/Windows/Linux/g' data > newdata
# awk '/vickey/ {print $1}' /etc/passwd
echo $PATH
which ls
This command shuts down the operating system, but can only be run by the root user.
#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 your root user.
#init 6
This command also shuts down and restarts the operating system. It also can only be run by root
#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
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
#locate
If this is all too time-consuming, RHEL 6 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,Getting into the Files
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.
#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/passwdcommand lists the last 15 lines of the /etc/passwd file.
#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:
# ln smb.conf /etc/samba/smb.confOn 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
#sort
You can sort the contents of a file in a number of ways. By default, the sort command sorts the contents in alphabetical order depending on the first letter in each line. For example, the sort /etc/passwd command would sort all users (including those associated with specific services and such) by username.#grep and egrep
The grep command uses a search term to look through a file. It returns the full line that contains the search term. For example, grep 'vickey' /etc/passwd looks for my name in the /etc/passwd file.The egrep command is more forgiving; it allows you to use some unusual characters in your search, including +, ?, |, (, and). While it's possible to set up grep to search for these characters with the help of the backslash, the command can be awkward to use.
#wc
The wc command, short for word count, can return the number of lines, words, and characters in a file. The wc options are straightforward: for example, wc -w filename returns the number of words in that file.#sed
The sed command, short for stream editor, allows you to search for and change specified words or even text streams in a file. For example, the following command changes the first instance of the word Windows to the word Linux in each line of the file data, and writes the result to the file newdata:# sed 's/Windows/Linux/' data > newdata However, this may not be enough. If a line contains more than one instance of Windows, the above sed command does not change the second instance of that word. But you can make it change every appearance of Windows by adding a "global" suffix:
# sed 's/Windows/Linux/g' data > newdata
#awk
The awk command, named for its developers (Aho, Weinberger, and Kernighan), is more of a database manipulation utility. It can identify lines with a keyword and read out the text from a specified column in that line. Again, using the /etc/passwd file, for example, the following command will read out the username of every user with a vickey in the comment column:# awk '/vickey/ {print $1}' /etc/passwd
#ps
It's important to know what's running on your Linux computer. The ps command has a number of critical switches. When trying to diagnose a problem, it's common to get the fullest possible list of running processes, and then look for a specific program. For example, if the Firefox Web browser were to suddenly crash, you'd want to kill any associated processes. The ps aux | grep firefox command could then help you identify the process(es) that you need to kill.#who and w
If you want to know what users are currently logged into your system, use the who command or the w command. This can help you identify the usernames of those who are logged in, their terminal connections, their times of login, and the processes that they are running.#env
This command displays the environment variables for the currently logged-in user.#echo
This command is used to echo a line of text on the screen. It’s frequently used to display environment variables. For example, if you wanted to see the current value of the PATH variable, you could enterecho $PATH
#top
This command is a very useful command that displays a list of all applications and processes currently running on the system. You can sort them by CPU usage, memory usage, process ID number, and which user owns them#which
This command is used to display the full path to a shell command or utility. For example, if you wanted to know the full path to the ls command, you would enterwhich ls







0 comments:
Post a Comment