The linux terminal for beginners
As I have used linux for quiet some time and having more experience with the console, the ways I use and control the system changes. Now and then I happen to use the console and as I do it more and more I start to like it. Especially since I the machine I use for linux is a laptop and not having a mouse to control, then it is nice to control everything with hotkeys and the console.
If you want to get startet using linux via the terminal, here is some easy commands you should know:
- sudo
runs a command as root (Super User Do). E.g. “sudo gedit” will open up Gedit as root. Whereas normal open from the gnome menu or similar opens the Gedit without root privileges. - ls
lists the items of the current working directory - cd
changes directory where you currently is working from. As argument you can give the exact part or go with a relative path - mv
move a file from one place to another. it is alsoe used for renaming a file. - cp
will copy a file from one destination to another. - unzip
is used to unpack zipped packeges - tar
is used for gzipped packages
The commands above are all very useful for basic file handling. To explorer the full posibilites of the commands use the command “man [command]” og try “[command] -help”. The man command will open up the manual for the given command. The -help will just show a shorter help message with basic options. Try it out and see what happens. But dont do anything as root unless you know exactly what you are doing and what will happen, you can end up doing harm to your OS installition.
For a little more advanced stuff, you can install/uninstall and run programs from the command line. Some programs are run directly in the terminal and some will open up another window for the programs gui (graphic user interface).To do this you will need some of the following commands:
- apt-get
is the a command line tool used for adding/removing programs. A parameter is required, for install you will need to enter “apt-get install” followed by the name of the package you want to install, and “apt-get remove” followed by the name of the package to uninstall.
The apt-get tool will search for the packages in the repositories added in the sources list, this can get complicated and you can search information on this on you own. I recommend taking a look at the man page for this, “man apt-get”. - [name of program]
will run the given program. You will of course need to know the name of the program you want to run. So, if you want to run the gedit (the standard text editor that comes with ubuntu) you can simply enter “gedit” and the program will show up. You can give the program an optional argument where the argument(s) is the name of a file you want to edit. You can put as many files as you want, but that is specific for this program. E.g “gedit file.txt”. Other programs will have other arguments. Every command is actally programs that run with or without arguments.
Sometimes when you work with you OS or want to customize something or change something you will need to edit certain system files that require root privileges. This is where it comes in handy to know some basic command line stuff. Say you need to edit the file /usr/foo/bar.txt for some reason but your user do not have writing access to the file. Then you will need to do something like this in you terminal:
sudo gedit /usr/foo/bar.txt
This will open the file in gedit and you will be able to save your changes. Very useful and easy to do once you get the touch with the terminal. It wont take long once you start doing it on a regular basis.