"One of the best ways to get yourself a reputation as a dangerous citizen these days is to go about repeating the very phrases which our founding fathers used in the great struggle for independence." --Charles Austin Beard
All of the following commands should work from your terminal, regardless what shell you are using.
If you need help understanding the command more thoroughly, or it's options, try adding --help to the end of your command. Example: Say you need help with the command "date," you would do "date --help"
Here are some basic linux commands:
cd. You use cd to change directories. Type cd followed by the name of a directory to access that directory. Keep in mind that you are always in a directory and allowed access to any directories hierarchically above or below. Example: cd games
If you directory games is not located hierarchically below the current directory, then you may use either of the following examples:
clear. Use clear to clear the terminal. Type clear to clean up your terminal window. This is especially helpful when you are typing lots of commands and need a clean window to help you focus. Example: clear
This is also useful when you are getting ready to type a rather long command or a command with a rather long output and do not wish to become confused or distracted by other details on the screen.
date. Use date to set your server's date and time. Type date followed by the two digit month, the two digit date, the two digit time, and two digit minutes. The syntax is easy enough and resembles this: MMDDhhmm
This command is helpful but must be used when superuser or logged in as root. Otherwise you will get an "Operation not permitted" output. As root or superuser, you can execute the command such as:
The above command will set the server date and time to the fourth month (April), the eighth day, at 5:39 PM.
df. Use df to check disk space. Typing df provides a very quick check of your file system disk space. Type df -h to get a more easily readable version of the output. Notice that this command will include all application storage such as your hard disk/s (hda, hdb, etc.) and your server SWAP file (shm). To list disk space including file system type, execute the following command: df -h -T
You could also combine -h -T by using df -hT
finger. Use finger to see who is on the system. Typing finger allows you to see who else is on the system or get detailed information about a person who has access to the system. Type finger followed by the name of a user's account to get information about that user. Or, type finger and press enter to see who is currently on the system and what they are currently doing. Example: finger johndoe
logout. Yep, you guessed it, typing logout will log your account out of the system. Type logout at the prompt to disconnect from your linux machine or to logout a particular user session from the system. Keep in mind that although rudimentary, leaving your critical account logged on may be a security concern. I always recommend promptly using logout when you are finished using your root account. Example: logout
ls. Use ls to list files and directories. Type ls to see a list of the files and directories located in the current directory. If you are in the directory named games and you execute ls, a list will apear that contains files in the games directory and sub-directories that are in the games directory. Examples:
Type ls -alt to see a list of all files (including .rc files) and all directories located in the current directory. The listing will include detailed, and often useful information. Examples:
ls -alt /usr/bin
If the screen flies by and you miss seeing a number of files, try using the |more at the end like:
ls -alt |more
* In bash, (linux shell) often the abbreviated command "L" is available. To get a verbose listing of files and directories, you could therefore simply type: l
man. Use man to pull up information about a linux command. Type man followed by a command to get detailed information about how to use the command. Example: man ls
Type man -k followed by a word to list all of the commands and descriptions that contain the word you specified. Example: man -k finger
more. Use more to read the contents of a file. Type more followed by the name of a text file to read the file's contents. Why do I emphasize using this on a text file? Because most other types of files will look like garbage that you will probably not understand. Example: more testfile.txt
nano. Use nano to start a text editor. Typing nano will start a basic text editor on most linux systems. Type nano followd by the filename you wish to edit. This basic editor is quick and easy to use for beginners. However, it is very important that you also learn about other text editors available on linux and UNIX systems. I searched for a page three other text editors: vi, pico, and emacs. You may go to http://www.reallylinux.com/docs/editors/editor.shtml to learn about those.
passwd. Use passwd to change your current password. Type passwd and press enter. You will see the message "Changing password for username."
At the old password: prompt, type in your old password.
Then, at the enter new password: prompt, type in your new password.
The system double checks your new password just in case you made a typo the first time typing it. Beside the verify: prompt, type your new password again. You may also change other user's passwords with this. Just use "passwd theirusername". Although, this does require root to change other's passwords.
pwd. Use pwd to print the name of your current working directory. Type pwd and hit enter. You will see the full name of the directory you are currently in. This is your directory path and is very handy. This is especially handy when you forget what directory you have changed to and are trying to run other commands.
Well, this is the article for now, and I will probably add on to it or make another article later on compiling, etc. Hope this helps you understand some of the basic commands for linux!
Don't forget to comment and vote!
Cast your vote on this article 10 - Highest, 1 - Lowest
Comments: Published: 12 comments.
HackThisSite is is the collective work of the HackThisSite staff, licensed under a CC BY-NC license.
We ask that you inform us upon sharing or distributing.