Tag: ps

Important Unix Commands That You Should Know

By Bernard Peh

Unix is one of the most important operating system today. Its powerful features, scalability, strong security, and support for multiple users have made it the top choice operating systems for server, workstations and mainframes.

It is good to have some knowledge of Unix commands especially if your web host is Unix/Linux based. You could do alot of things by yourself by logging into the server via Secure Shell(SSH). This article will describe some of the important “need to know” Unix commands.

1. ls

This command will show you what files are in your current directory. If you add in a -F option, ie “ls -F xxx”, there will be a “/” appended to the end of directory names, * to executables and @ to links. “ls -a xxx” will display all hidden files as well. This is also the most used command.

2. cd

Change directory. If you type “cd xx”, it means to change to the specified directory “xx”. “cd ~” means to change to your default home directory.

3. cp “a b”

Copy file a to b. If b is a directory, the new file will be named b/a.

4. mv “a b”

Move files from a to b. For example, if I type “mv songs.txt /tmp”, the file songs.txt will be moved to /tmp/songs.txt. Moving a file is the same as renaming a file.

5. echo “text”

Print “text” to the terminal. If “text” is surrounded by double quotes, the text will be printed with any environment variables such as $HOME. If “text” is surrounded by single quotes, the “text” is printed without any special processing.

6. pwd

Print the current working directory. Useful command when you are lost in the directories.

7. cat “file”

Print the contents of the specified file(s) to the terminal.

8. less “file”

Display the specified file one screen at a time. Press the spacebar to go to the next screen. Press Q to quit. You often combine “less” with some other commands such as “cat abc | less”. This command means you print the contents of the file abc and display it one page at a time.

9. ps

Display information about your running programs. This is a good command to use if your server is slow and you suspect that some applications are taking too much memory. The most famous command using ps is “ps aux”. This will display useful information on the running programs.

10. rm

Remove or delete a file. If you type “rm -r directory”, it will remove a directory and all the files underneath it recursively.

11. man

This is the most important command. man means “manual”. If you are stuck with cat command for example, type “man cat” and you can see the help file.

Bernard Peh is a great passioner of web technologies and one of the co-founders of SiteCritic Website Reviews. He works with experienced web designers and developers for more than 5 years, developing and designing commercial and non-commercial websites. During his free time, he does website reviews,freelance SEO and PHP work.

Tags: , , , , , , , , , , ,

An Introduction to Linux Shell Commands

By Erick M Aqqa

The Linux system often intimidates beginners, what with the need to type in a command or two every now and then. However, Linux commands (or shell commands, to put it more accurately) follow a rather logical and sensible pattern and all you need to do is get used to it! Most shell commands are roughly 3, or at most 4 letters long. The more frequently needed commands are shortened further usually.

The man command is a reference to ‘manual’, i.e. the documentation that comes preloaded in Linux systems to help you with common problems faced by a user. These man(ual) pages are certainly not meant to be standalone guides for beginners, but instead, they need to be used as reference material to corroborate what you’ve learnt/tried elsewhere.

The info command is another way to look up reference material for GNU information and troubleshooting suggestions. It isn’t completely the same as the man pages, as there is a scope for using ‘hyperlinks’, to make it easier to browse through the material you need. There are shortcuts for scrolling through pages too.

The date command is self-explanatory. It will tell you about the current time and date on the system. On those lines, the cal command will display a neat calendar of the current month (or that of any particular one you choose).

The ls command is meant to help you list the contents of the directory you choose. This means that you will get to see all the files and directories inside your current directory.This command also has switches to modify its behavior and functionality. For example, adding -l after ls will give you a more detailed description of the contents of the directory you’re in. you’ll get to see details about file permissions, modification dates, groups, sizes and owners. The -a switch helps you see all the files in your current directory, including the hidden ones. (Hidden files in Linux have their filenames starting with a ‘.’ i.e. a period)

In case you lose track of the current directory you are in, type pwd, which prints the current directory you are working in. Once you’ve got to know that, you can navigate around the Linux file system using the cd command, where ‘cd’ stands for ‘change directory’. This can work on both relative and absolute terms, i.e., you can work by specifying the entire directory, starting from ‘/’ (the home directory) to the directory/file you want to go to. Otherwise, you can also use the ‘.’ or ‘..’ system. The latter tells the compiler that you want to go to the parent directory of your current one, making it an easy alternative to typing the entire path every time.

When you start working with simple files, like text files, the cat command will come in handy. It ‘concatenates’ the content of one or more text files, letting you see all of the text they contain.

The ps command lists all the processes currently running on your system in your current terminal.

The shell commands in this article are a good way to start off in the Linux environment. They are simple enough for you to get an idea of how the entire system works, and will probably help you to try out more advanced steps later!

To know more about Linux shell commands, click here

Linux2Aix is an upbeat Linux blog containing all the latest and the newest Linus news and how-to’s for both amateur and professional Linux lovers

Tags: , , , , , , ,

Linux Command Syntax and Command Help

By Andrey Jone

Linux Command Syntax can be very confusing. To compound matters, every command has slightly different Syntax. When you enter a command you will need to know what switch or options to use. This will allow you to turn a common command into a powerful tool.

One important thing to keep in mind is letter case. In Windows it does not care if a letter is capital or lower case. In Linux alphabet case matters. If you were to type “find” and “Find”, Linux would view these as totally separate entities. “find” is the command to search the file system. With the correct options it would perform a system search. “Find” is not defined, it will error out. Linux also does not like spaces. You should not name a file or directory including a space. If you are using multiple words you can divide the two words with a symbol such as “this_directory”

Command Help

For every command there are two levels of help. This will allow you to begin learning about what that command can do. The first way to look the help screen is this:

"commandname /help" or commandname /?"

This will give you a good starting point to learn the command options and syntax.

The second level of help is called a man page. “man” is short for manual. Most commands have a man page and its normally a couple pages of information about the command you are using. You can see any of the man pages by typing:

"man commandname"

Special care should be given when typing any Linux command. In Linux normally quotes are used to define and separate variables. In some cases multiple command options can be separated with commas. This is normally for user input though. For a simple idea about syntax we can break down the find command here:

find / -name 'httpd.conf'

Here we have the find command, the “/” states what directory to search in. I have chosen root, however you could just as easily put any directory name. The “-name” basically tells find you are searching by name. Finally I have put the name in single quotes. In this case the quotes are not required.

Certain commands in Linux can be used with other commands. You can use “|” the pipe command to pipe output of one command through another. Such as

ps -ef | grep httpd

This is a process command to list all process’s. However you are taking the output of this command an piping it to the “grep” command. In this case it will only show the process’s associated with “httpd”.

Another command switch that works for most any command is “>” .

"find / -name httpd > list"

This will print the command output to a file called list.

Linux command syntax is hard to pick up at first. However through learning you can unlock the unlimited potential that your Linux System has to offer. Much more information about Linux commands can be found online. There are many good resources that will help you learn the commands of your Linux system. By using online sites, the man pages and command help you can soon become very familiar with your system.

Andrey Jone shares his views about Linux Command Syntax and Command Help. For more information on Linux Command Syntax and Command Help, please visit http://www.webhost.org

 

Tags: , , , ,
Back to top