From Mageia wiki
Jump to: navigation, search
Drakconf multiflag.png
Other languages

Deutsch ; English ; Français ;

This page is a draft. It requires improvements.

If you want to improve it, simply log in and click on the edit tab.
Please remove this {{Draft}} template, when you're sure the page is complete and correct.

View the other draft pages

View all other pages to improve and maintain.


This page is written with absolute beginners in mind (mostly those coming from Windows) and deals with the Command line. The goal of this page isn't to teach the computer management with command line, there is plenty of pages about it in the Internet and in this wiki.(see Links)
This page, voluntarily light, aims at introduce the reader to something he often doesn't even know the existence, and to prompt him, if he likes it, to go on with other pages.

What is the command line for ?

It is a way to give orders to the computer using commands that are characters strings typed in an area called "Console". A question that may have crossed your mind is "Why should I bother learning the command line? The Graphical User Interface (GUI) is much easier and I can already do most of what I need there." Well, you are generally right, but there is situations where the command line is very helpful:

  • When the graphical interface doesn't work, unlike Windows, Linux can run without any GUI. The command line, for example, may be the only way to reboot properly.
  • Command line are very often more accurate (more options) than a GUI.
  • During its execution, the command line gives you more information about the done job (verbose mode). If a graphical application doesn't start for example, try a start in a console, you will know much about the problem.
  • Command line needs less hardware resources.
  • The commands are always available on any computer running Linux not the graphical tool.
  • The commands are roughly the same in any Linux distribution.
  • Give and/or receiving help is more easy with command line. It is often confusing and long to explain where to click in the multiple pages of a GUI, while a copied/pasted command in a console is always easy to do. With regard to forward the system answer to the helper, once more a text copy/paste from the console is easy to do while the same answer through a GUI is not always.

How to find a console

Each desktop environment allow to open a windows for command line. It is called Konsole for KDE, Terminal for Gnome, Xfce, LXDE, Mate, ... Its icon looks like an old PC screen.
You can find it in the menu, for example Menu Mageia -> Tools -> Konsole for KDE or Applications -> System tools -> MATE Terminal for Mate or Menu Mageia -> Tools -> LX Terminal for LXDE,...
Another way is to hit simultaneously the keys Alt+Ctrl+Fn, with n being a number between 2 and 6. You are then leaving the graphical interface (but is still running), come back hitting Alt+Ctrl+F1.

What is root ?

As a user, your rights are limited in order to protect the system. You can read files everywhere, but you can modify them in /home/user subdirectories only. Root is the "Administrator", he has all the rights, including breaking everything. So be root only when really necessary and be very careful when you are root.

To become root, open a console and enter: su - (don't forget the -). A password is asked, but not printed of course. To be user again, enter: exit.


Good to know


Instead of writing the whole command or directory name, just write the first letters and type the TAB (tabulation) key, the system will complete the name. the advantages are:

  • save time
  • avoid typo errors
  • acts as memory help, if you don't remember a command or file-name spelling, enter the beginning and the system lists all the possibilities matching the first letters. (see next screen-shot).


Linux and the console are case sensitive, that means image.jpg, Image.jpg and Image.JPG are different file-names.


To copy from an application to a console, select the text as usual (hit the keys Ctrl+C or Edit -> Copy) and then paste in the console with a central (or wheel) click; or Edit -> Copy
To copy from a console to an application, select the text, then use the menu Edit -> Copy, and then paste in the application with a central (or wheel) click; or Edit -> Copy.

Commands historical

You can use the arrows keys UP and DOWN to navigate in the commands historical, very useful when you want to re-use a recently used command

Navigation in the filesystem

It is of course possible to use the console as a file manager (like Dolphin, Nautilus or Thunar). A console opens in the folder /home/<user>.

  • pwd (Print working directory) -> to know where you are
  • cd (Change directory) -> to go elsewhere. Example: cd /home/<user>/Documents/linux. This example is called an absolute path, it starts at /. If you are in /home/<user>, you can more simply write cd Documents/linux. It is called a relative path, it starts where you are. (take care to the case !)
  • cd .. -> to go in the parent directory
  • ls -lh -> to list what is in the directory. The rights are given in the first column, if they start with a "d", that means it is a directory. Columns 3 and 4 are the owner and the group owner names, then the size, the last saving date and the file name.



Simple commands to know my computer

Here are some commands to investigate your computer, they are harmless, use them with user rights.

  • What is my Mageia version ? -> cat /etc/release. cat means print and /etc/release is the file-name housing this information.
  • And the Linux one -> uname -a
  • How is used my computer memory -> free
  • What is consuming the computer resources -> top. You can see here what are the command (command column) consuming the largest CPU (%CPU column) and memory (%MEM column) resources.

This command is always running and updating, use Ctrl+C to stop it.

  • How many bad blocks in my partition -> e2fsck -cyv /dev/sdxy

You must be root to execute this command. Replace x by the HDD letter and y by the partition number, for example /dev/sda5. This partition must be unmounted. If the system says it is mounted, check that you are not using it and enter the command umount /dev/sdxy.

You will get something like that:

[root@localhost ~]# e2fsck -cyv /dev/sda5
e2fsck 1.42.9 (28-Dec-2013)
Checking for bad blocks (read-only test): done                                                 
/dev/sda5: Updating bad block inode.                                                            
Pass 1: Checking inodes, blocks, and sizes                                                      
Pass 2: Checking directory structure                                                            
Pass 3: Checking directory connectivity                                                         
Pass 4: Checking reference counts                                                               
Pass 5: Checking group summary information                                                      
/dev/sda5: ***** FILE SYSTEM WAS MODIFIED *****

       99138 inodes used (14.85%, out of 667808)
          66 non-contiguous files (0.1%)
          48 non-contiguous directories (0.0%)
             # of inodes with ind/dind/tind blocks: 0/0/0
             Extent depth histogram: 91901/26
     1028346 blocks used (38.55%, out of 2667776)
         115 bad blocks
           1 large file

       83802 regular files
        8028 directories
           1 character device file
           0 block device files
           0 fifos
        1465 links
        7298 symbolic links (7202 fast symbolic links)
           0 sockets
      100594 files
[root@localhost ~]# 
  • Last installed packages -> rpm -qa --last. Next page with the Space key, exit with Ctrl+Z

If you want more commands to investigate your computer, see the fourth link in this section: Links

Simple commands to modify my computer

These commands need root rights, thus they may break things if not duly executed as said.

Here are some commands you may be very happy to find if some day your computer doesn't work properly.

Software management

you must replace mageia4 by the wanted release and x86_64 by i586 if you use a 32 bits version. Note that Nonfree and Tainted sources are installed and activated.

  • Update -> urpmi --auto-update --auto (execute twice if used after new sources installation)

Mounting and unmounting

These commands are very useful for example if you try to fix a computer using a Live CD/DVD. You have to mount the folders by hand before being able to have access into it.

  • Mounting sdb1 into /media -> mount -t ext4 /dev/sdb1 /media. ext4 is the sdb1 format. You may have ext3, vfat (DOS) or ntfs-3g (Windows XP and after).
  • Mounting a floppy -> mount -t vfat /dev/fd0
  • Mounting a CDROM -> mount -t iso9660 -r /dev/cdrom
  • Unmounting -> umount /dev/sdb1. Note there is no n before the m in the command name: umount
  • Suppose you want to see your USB keys automatically mounted in /media instead of /run/media/<user>/<key name>, open kwrite and copy paste:
ENV{ID_FS_USAGE}=="filesystem|other|crypto", ENV{UDISKS_FILESYSTEM_SHARED}="1"

Save the file in /etc/udev/rules.d/99-udisks2.rules


  • To change a driver -> See the fifth link in this section: Links
  • To halt properly the system -> shutdown -h now without reboot, shutdown -r now with reboot.


  1. URPMI
  2. How_to_do_some_easy_commands
  3. As_easy_as_a_shell
  4. How_to_ask_help
  5. How_to_change_a_wrong_graphic_driver