Linux commands and their uses

There are a vast array of different commands for Linux, the commands I am going to list below are for Ubuntu, but they will work on most distributions especially if the distribution  is Debian based.

I am going to start with very basic commands and as I learn more I will add them here. also a helpful hint is any command you come across that you don’t know how to use then if you type that command followed by “–help” it will then display the correct syntax and any other information such as available switches etc.

Date” command, as you can see, will just print out the date and time to the screen. if you were writing a bash script, you may want to add the time and date to the log file perhaps, this is when the date command will come in handy.

ls” command which means list, lists the contents of a directory, if you are familiar with DOS back in the day, it is the same as the “dir” command.

The next command will be “cd” or change directory the same as it would be in DOS. Say if we wanted to go into the “home” directory, we could just type “cd home” but if we were not in the directory that the home directory was in the we would have to add the / so the syntax would be “cd /home”

Another command which I don’t use and I really don’t see much point of it is the”cal” command which I would of though you would of guessed what it does. it prints the calendar to the screen. I guess it could be helpful if you wanted to know what day a particular date is but we do have smart phones now!

There are three other commands that are really useful, these commands are…

PWD – prints working directory, this is handy if you don’t know how far up the directory tree you are.

 

CP – copy file this will copy a file from one directory to another.

 MV – move file. This will move a file from one location to another.

Getting a bit deeper into the terminal there is another command that is useful and this is the “df” command as you can see above this prints out all the disks that are mounted on your system, and displays the available disk space of each.

The command “Free” will display free memory on the screen. this has switches you can use if you type “freehelp” then a list of available switches will show on the screen as you can see with the image below. to enable a switch you will need to type “free – m” for example if you wanted it to be displayed using megabytes.

 

 

 

 

 

 

 


Editing Sources

Sometimes you may want to add repositories to your “sources.list” file this is particularly useful if you want to keep a package updated by using “apt