Highly useful Linux commands &

configurations

Oh, you're gonna love this article! Even though there are
many websites hawking similar content, with varying degree
of clarity and quality, I want to offer a short, easy-to-use
guide to some of the most common yet highly useful
commands that could help make your Linux experience
more joyful.
Now that you have read some of my installation guides, you
have probably setup your system and configured the basic
settings. However, I'm positive that some of you must have
encountered certain difficulties - a missing package, a
missing driver. The initial effort required of a Linux novice
can appear daunting, especially after many years of
Windows discipline.
Therefore, this article was born, in order to offer simple
solutions to some of the more widespread problems that one
might face during and immediately after a Linux installation.
It is intended for the beginner and intermediate users, who
still feel slightly uncomfortable with meddling in command
line, scripts or configuration files.
This article will refer to Ubuntu Linux distribution as the
demonstration platform. However, all of these commands
will work well with many other Linux distributions, with only
small changes in syntax, at most. I have personally tested
and used all of the commands and configurations in both
Debian-based and RedHat-based distributions with success.

What am I going to write about?
Here are the topics. If you want to skip through some of the
paragraphs, you can use the table of contents further below,
but I recommend you read everything.

Basic tips - avoiding classic mistakes.

Commands - an introduction to the command line.

Installation of software - including extraction of
archives and compilation of sources.

Installation of drivers - including compilation, loading,
configuration, and addition of drivers to the bootup chain,
writing of scripts and addition to the bootup chain.

Mounting of drives - including NTFS and FAT32
filesystems and read/write permissions.

Installation of graphic card drivers - including
troubleshooting of stubborn common problems.

Network sharing - how to access shared folders in
Windows and Linux from one another.

Printer sharing - how to share printers in Windows and
Linux from one another.

Some other useful commands.

Table of contents

1.

Basic tips

2.

Commands

1.
3.

Asking for help
Installation of software

1.

What should you choose?

2.

Discipline

3.

Unpacking an archive

Installation of graphic card drivers 7. Scripts 5. Zipped archives 5. 2. Listing information about files and folders 5.4. Printer sharing 9. Loading drivers 3. Other useful commands 1. Windows > Linux 2. Installation 6. Compilation (from sources) 7. Summary of installation procedures 4. Linux > Windows 8. 1. Installation 2. Installation of drivers 1. Configuration of drivers 4. Display system environment information 4. Network sharing 1. Mounting a drive Other options 6. Switching between runlevels Backing up the X Windows configuration file (useful before graphic drivers update) 3. Kill a process .

Even though you may not see the HDD light blinking and the execution takes a very long time. especially scripts and configuration files.  Before copying. unless explicitly declared with double quotation marks ("like this"). you should rename the file to RedGemini. typing p then TAB will automatically complete the name regardless of its length. For example: Red Gemini.doc is a valid Windows filename.  Pressing TAB when typing a command will autocomplete the command. the command will complete the maximum available part of the string that matches all relevant filenames (s + TAB for smirk and smile will auto-complete to smi).  It is best to create folders and files in Linux WITHOUT spaces.doc. Linux almost never gets stuck. be it 5 seconds or 5 hours. moving. but you might have problems accessing it from the command line in Linux. Let the command complete.Basic tips There are some things you need to know before heading into the deep waters of the Command Line:  Linux commands are cAse-sensitive (dedoimedo and Dedoimedo are two different files). if you have more than one file. do not assume the system is frozen.  Do NOT stop the commands while they are running (by pressing Ctrl + C). For example: if you have a single file in a certain folder that begins with the letter p. Just for reference. Unlike Windows. compilation of certain programs can take a few days to complete. deleting. Commands . or tweaking any file. Users of the DOS command line are also familiar with this problem commands will fail on folders and files with more than a single word. it is best to back them up first.

you cannot figure out the syntax required to use the file.org Some Useful Linux Commands Locally. If. you need to be familiar with some rudimentary Linux commands. Installation of software Although most Linux distributions offer a wealth of useful programs.To be able to use the command line. Below you can find links to some of the basic Linux commands: Alphabetic Directory of Linux Commands An A-Z Index of the Linux BASH command line LinuxCommand. Former users of DOS will find the transition very simple. you will probably be compelled to try new . some_command ­­help The above usage will display a summary of available options for the command in question. you can ask for help. inside the command line terminal. for some reason. help is one of the most useful features available to the command line user. There are two ways of doing it: man some_command The above usage will display a full help file for the command in question in Vi text editor. You will most likely prefer to use this second way. You can learn more about Vi from An Extremely Quick and Simple Introduction to the Vi Text Editor.

deb extension. 2. Discipline This may sound harsh or strict. You probably ask yourself: What now? The answer is very simple.exe installers and will unpack and install automatically. What should you choose? The logical choice for the novice user should be 1 > 2 > 3. but certain unspoken rules are followed. but the user will have to install them manually. which simplifies the use of software downloads. usually archived. This option offers more control during the installation. In addition to better control of the installation. after unpacking the archive. There are three versions to your downloads. Compiled packages.gz or tar. most likely packaged inside an archive. from the easiest to hardest: 1. . from the command line. like Synaptic. the downside is that the user has no control over the installation script.bz2.tar extension. 3. Geeks will most likely ever only compile from sources.rpm or . Some programs will be available for download via package managers.products. These archives will contain all of the necessary files required to make a program run. Intermediate users will probably try 2 > 3. the user will also benefit from software optimized to his hardware configuration. These packages are identical to Windows . Sources. usually with . Others will only be found on the developer's site. The user will have to unpack the archives and then compile the sources before being able to actually install the program. with . These archives will also most likely be compressed and bear a double extension like tar. The upside of the packages is the relative use of their deployment. Compiled archives. called tarballs.

Here are a few common examples: tar zxf some_software. But the problem is easily solvable. In our case. we have the ability to "ask" for help for each unknown command. If you recall.tar. we need to know how to unzip an archive. unzip ­­help . an explanatory text on the download page or bundled with the download. either as a standalone file. prior.  A secondary how-to will most often be packed with the program.  You should read this how-to FIRST before installing the software. This might put you off. The only difference will be in the arguments used for unpacking.  You should read this how-to FIRST before downloading / manipulating the software. The program itself will almost always be accompanied with a how-to.gz tar ­xjf some_software.tar. The how-tos are most often found on the site you download the software from.bz2 You can read in detail about the handling of tarballs on the Wikipedia site. Unpacking an archive The exact syntax will differ from one package to another. But the general idea is the same for all. during and after the installation. explaining the installation process itself. usually in a form of a text file that explains what a user should do. Zipped archives Some archives will be zipped rather than tarred.

Here's a screenshot I took. in our case a temporary folder called /tmp. depending on the language used to write it. you will now have to install the software.zip ­d /tmp Reading from the help screen above. we want to unpack our archive into a folder. depicting the very dilemma we are facing . The exact name of the script will vary from one program to another. Installation After unpacking the archive. the installation is invoked by using a script. as well as its extension. Usually. . The argument -d tells us that the contents of the archive will be extracted into a destination directory (folder).and its solution: A possible usage will then be: unzip some_software.

You just need to remember three simple commands: This first command will generates files required to build the software and setup system-wide parameters. Summary of installation procedures . The archives will contain lots of files with curious extensions like . you could use some reading: Compiling and installing software from source in Linux There is no guarantee that the compilation will succeed.For example.o.pl (written in Perl). . the programs will not be compiled and ready to install. where you are most likely to find an answer rather quickly. Likewise. the following command will invoke the script named install. . make This third command will install the libraries and applications.h and . you should make note of the errors and post them in relevant forums. Some sources are broken! In that case. .pl Compilation (from sources) Sometimes. Dot and trailing slash indicate that the script will be executed within the current directory./install. you should not bother understanding what they are and what they do. make install For homework.c./configure This second command will build the libraries and applications. you need not understand how the compilation of sources is made. If you are not a programmer.

They serve the purpose of making your hardware components understand each other.tar. You should contact your vendors for that information. As simple as that.bz2 cd some_software_directory . the necessary drivers will be included with the distribution and installed during the setup. you will need root privileges (su or sudo) to be able to install software.tar.gz OR tar ­xjf some_software. you might not be so lucky and will reach a newly installed desktop without sound. Most likely. Most often.you do not actively use them. how to ./install_script An archive containing sources: tar zxf some_software. network or video drivers. like any software.gz OR tar ­xjf some_software. An archive containing compiled program: tar zxf some_software.To make things easier to understand./configure make make install Installation of drivers Drivers are programs. I will not go into details explaining how specific drivers are installed.tar. The only difference is . Sometimes.bz2 cd some_software_directory . You need them to enhance your usage of the operating system.tar. I will explain how to install the drivers. below are two examples showing the list of necessary commands required to run to successfully install a downloaded application (please note these are ONLY examples!).

Drivers will usually be distributed as sources. it is possible that the driver will be accompanied with a self-installation script.load them. but will not be configured nor system paths updated.  The driver will be auto-configured and the system paths updated. drivers may be compiled or not. You will have to manually load the driver and then update the list of drivers loaded during the boot to enable it every time the machine starts. Most often. If the vendor is benevolent. Piece of cake.or might not even work. This means you will have to compile from sources. you will need to run only one command. Therefore./configure. in order to achieve maximal possible compatibility with the hardware on the installation platform. This means you will only have to add the driver name to the list of drivers loaded during the boot to enable it every time the machine starts.  The driver will be ready to use. We already know how to do that. After successfully extracting the archive and compiling the sources (. You will not need do anything special to use the driver. so they will load automatically every time your machine starts. But this might not be the case . you will most likely be faced with three choices:  The driver will be fully configured and copied to default directories and the system paths updated. for all practical purposes. and then how to add them to startup. make. which will in turn extract the archive. The second option will make the installation process probably look like this: . Installation Just like any software. compile. you should probably manually install the driver. install. and load it. In other words. they will not be. make install). I have personally witnessed a driver self-installation script go wrong.

but first we will back it up! Please remember that you need root privileges to meddle with the configuration files. exit the text Loading drivers You have successfully compiled the driver.bak gedit /etc/modules.conf inside the gedit text editor. This is your driver and you need to manually load it./configure make make install Optional . you will notice a file with . This is because the driver is not yet enabled.tar zxf some_driver. In Linux. Looking inside the directory. the file is called modules. but nothing has happened yet. You need to open the configuration file containing the list of modules. This is what our procedure would look like: cp /etc/modules./setup_driver_script All that remains is to add this driver to the list of drivers loaded at bootup.conf).conf /etc/modules.gz OR tar ­xjf some_driver. .conf and is found in /etc directory (/etc/modules.conf.ko extension. the drivers are often referred to as modules. You should refer to your specific distribution for exact name and location of this file. Simply add your driver in an empty line below the existing drivers.bz2 cd some_driver_directory .conf The above commands will open the file modules. In Ubuntu. save the file.tar. We will update this file.tar.

ifconfig eth0 192. The assigned IP address tells us the machine will be part of a LAN network.9 .0. Most often. you can list all the available modules: lsmod If by some chance you have made a terrible mistake and you wish to remove the driver.168. In this particular case.168.ko ifconfig eth0 192. eth0 was the selected device name.0.9 After a reboot. You will have to repeat the entire procedure again: cd driver_directory insmod driver. instructions will be included in the how-to text files. cd driver_directory insmod driver. eth2 or any the name. To verify that the driver is indeed present. This can be done using the insmod command.We need to install the driver into the kernel. The network card is assigned an identifier and an IP address. although it could be also eth1. the example demonstrates how the network card is configured after the network driver is loaded. This is because your driver has not been created in a common default directory and the system does not know where to look for it. Below. it can be configured. you will realize that you no longer enjoy a network connection.ko After the driver is loaded. you can use the rmmod command: rmmod Configuration of drivers Configuring the driver requires a bit of knowledge into its functionality.

ko ifconfig eth0 192.bat will convert the file to a script. We need to make it into an executable file. The most common (and default) Linux Shell is theBASH.ko ifconfig eth0 192.d directory so that it will be run during bootup.txt extension to .0.168.168. Linux command line lives inside a shell .9 Now. . There are several Shells. Or rather a text file that contains the relevant commands. if we wish to make it communicate with our Shell.or more precisely Shell. First. In the Windows department.9 We can also make it shorter: #!/bin/bash insmod /home/roger/driver_directory/driver. This is exactly what we're going to do . Scripts Like in DOS and Windows. In Linux. To make the script executable: chmod +x network_script Now we have a real script. We need to add this information to our script. Let's call itnetwork_script.0.You now realize that an automated script would be an excellent idea for solving this problem. the above commands + Shell addition will make the following script: #!/bin/bash cd driver_directory insmod driver. we need to save the file. Therefore. simply renaming the .write a script and add it to bootup. We need to place it in the /etc/init. However. things are a bit different. special changes are needed to separate between text files and scripts. scripts can be written in any text editor. each with a unique set of commands. we have a script.

so it will take our script into consideration. you just might be unlucky and your Linux refuses to see the drives despite your best efforts. Alternatively. both in Windows and Linux. but you have resized and relettered and renamed the partitions and they are no longer recognized by Linux. Finally. My method un-elegantly escapes this problem. update­rc. you will realize that your driver loads automatically and that your network card is configured! Alternatively. you need to know how your drives are ordered and what they are called. To be able to do this correctly. you might be able to see them.when you're booted in Linux. Compared to the above tasks. This means you will have to reinstall them again after every such update.ko Or you could place the driver in this directory by yourself. you might have formatted the drives. This means that some of these drives might not be mounted . my method. but you cannot write to the NTFS drives and this irks you so. Furthermore. This requires that you be able to . it is entirely possible that you have installed your Linux before you have formatted all the Windows drives. even if not the most elegant one. This way.d network_script defaults After you reboot. it is possible that the make install of the driver will place in the default directory: /lib/modules/<KERNEL  VERSION>/kernel/drivers/net/driver. Mounting a drive If you run a dual-boot system.d/ And finally. has one advantage: Drivers that you have manually compiled and placed into the default directories will be lost every time you update the kernel. mounting drives is a simple job. However. we need to update the system. you will be able to avoid the step of writing the script.cp network_script /etc/init.or accessible .

FAT32 partitions are writable by default. hda4. . but it can help relate the mounted drive to its Windows designation.  hda2 will be Windows F:\ drive . hdb2etc.  hda3 will be Windows G:\ drive .) and Linux partitions (hda1. before you mount a drive. G:\.  hda6 will be Linux (your /home). Namely:  hda1 will be Windows C:\ drive. when booted in Linux. Now.  hda4 will be Linux swap / Solaris. First. this is hda2. list the Partition Tables: fdisk ­l For the sake of this exercise. This is most conveniently done by assigned a directory within the /media directory. Then. although write access can also be enabled.also called Games. For example: mkdir /media/data The name data is arbitrary.correlate between Windows partitions (E:\. By default. Like before. K:\ etc. you need to create a mount point.  hda5 will be Linux (your /root). let's assume that Linux partitions are hda4-6. There are several ways of mounting the drive. mounting the drive only once will hold valid for the current session. Now. After reboot. make sure you know the order of your partitions in Windows.also called Data. the changes will be lost. while Windows partitions are hda1-3. we need to mount the drive that corresponds to data. In our case.). NTFS partitions are mounted asread-only.

NTFS read-only: /dev/hda2 /media/data ntfs nls=utf8. if you have partitions formatted with FAT32 file system or you wish to be able to write to NTFS partitions from within Linux.umask=000 0 0 NTFS read/write . we need to add the mount command. mkdir /media/data cp /etc/fstab /etc/fstab. you can use the following commands: FAT32 read/write: /dev/hda2 /media/data vfat iocharset=utf8.Therefore. we need to add the mounting of the relevant partitions to the boot chain.  Add a new line to the fstab file .  Backup fstab.requires installation of software that can write to NTFS drives.locale=en_US. in order to mount the NTFS drive (Windows F:\ drive called data) as read-only we need to:  Create a directory called data within /media. Therefore.umask=0222 0 0 Other options Alternatively. apt­get install ntfs­3g /dev/hda1 /media/data ntfs­3g  defaults. The configuration file that holds this crucial information is called fstab and is located under /etc (/etc/fstab).utf8 0 0 .that will mount the NTFS drive hda2 (Windows F:\ -data) as read-only.bak gedit /etc/fstab After opening the file in the text editor.

you can install the graphic card drivers using a Package Manager or via the command line.but some of the solutions presented work for both Nvidia and ATI cards. The first method is embodied in these two commands .the download of the required package and the installation of the driver: apt­get install nvidia­glx nvidia­glx­config enable . the first method should work flawlessly. ALL of which have Nvidia graphic cards .utf8 0 0 /dev/hda2 /media/data ntfs nls=utf8. read-only NTFS partition F and use FAT32 partition G. the list of commands that we need to execute is: apt­get install ntfs­3g mkdir /media/windows mkdir /media/data mkdir /media/games cp /etc/fstab /etc/fstab.umask=0222 0 0 /dev/hda3 /media/games vfat  iocharset=utf8. In that case.An exercise: Let's assume we wish to be able to write to NTFS partition C.locale=en_US. Although I have already discussed the installation of graphic card drivers in my Installing SUSE Linux and Installing Kubuntu Linux articles.umask=000 0 0 Installation of graphic card drivers Please note that commands used in this subsection are for Nvidia drivers ONLY . I think a bit of extra guidance will not hurt anyone. For most people. Basically.bak gedit /etc/fstab ADD FOLLOWING LINES TO FSTAB /dev/hda1 /media/windows ntfs­3g  defaults.I have several computers.

you need to install your driver: sh NVIDIA­<DRIVER VERSION>. You will probably need to login. The first six consoles provide a text terminal with a login prompt to a UNIX shell. you will see an error message indicating that the X Server has been disabled and that you need to manually edit the settings in the xorg. you literally need to stop the desktop from running. /etc/init. Reboot your machine just to make sure. It is possible that you will only see a black screen and no command prompt. Now.Some people might prefer to install the drivers manually. it may occur that by stopping the X Windows you will have simply switched off the graphics AND remain in the 7th virtual console. To do this. Do not be alarmed! Linux operating system usually has 7 virtual consoles.conf file before being able to proceed to the desktop. you should simply restart the X Windows.d/kdm start OR /etc/init.d/kdm stop OR /etc/init. therefore having no command line to work with. All you need to do is switch to one of the text consoles by pressing Alt + F1-6 on the keyboard.d/gdm stop OR /etc/init. there are .run After the installation is complete. The 7th virtual console is used to start the X Windows. This is where you might encounter a problem.d/xdm start If you see an Nvidia splash logo.d/gdm start OR /etc/init. /etc/init. with the X Windows stopped.d/xdm stop The desktop should vanish and be replaced with a command line. Instead of the Nvidia logo. Now. In other words. it means the driver has been successfully installed.

d/nvidia­* After the offenders are removed.4 xserver­xorg­dev apt­get ­­purge remove nvidia­glx nvidia­settings  nvidia­kernel­common rm /etc/init. Now. execute the following commands: The offending built-in driver needs to be disabled. sometimes.many possible reasons for such an error and trying to provide a general solution is impossible. you should remove all conflicting files from your system: apt­get install linux­headers­`uname ­r` build­ essential gcc gcc­3. This will prevent the built-in driver from loading and interrupting with your own installed driver.run nvidia­xconfig ­­add­argb­glx­visuals /etc/init.d/gdm start . you should install the drivers from the command line: /etc/init. gedit /etc/default/linux­restricted­modules­common Change the last line to DISABLED_MODULES="nv". Method 1: Do it yourself First. you will have probably used the default configurations and the generic kernel will have been installed. There are two methods for solving this problem.d/gdm stop sh NVIDIA­<DRIVER VERSION>. download the required driver. the built-in Nvidia driver (nv) might interrupt with the installation. I this case. Then. However. I have found the following argument to hold true for many cases: If you have setup your Linux distribution using the GUI installer.

Reboot just to make sure there are no more surprises. you will have to restart the Samba server: /etc/init.There is no reason why you should not continue doing this if one of the machines is running a Linux distribution. Sharing can be accomplished in many ways.bak gedit /etc/samba/smb. .conf. First. HOME)  netbios name = netbios_name .Again. Perhaps the simplest is using Samba server. This should get you up and running with the latest graphic card driver.conf In the configuration file.conf /etc/samba/smb. select a folder that you wish to share. install Samba: apt­get install samba After the Samba server is installed.g. you will need to edit a few options in the configuration file to allow sharing privileges.d/samba restart Now. you will need to setup a number of parameters:  workgroup = workgroup_name .the name of the Workgroup for your LAN (e. you are probably sharing resources among them. computer alias by which you will be able to call it across the network  security = user After saving the configuration file.without spaces. you should see the Nvidia splash logo. cp /etc/samba/smb. Network sharing If you have more than one computer.

xxx OR \\netbios_name When asked for username and password. you will be able to modify the contents of this folder. to be able to connect to this share from Windows. you will have to create a Samba user: smbpasswd ­a 'name' Under 'name' you should specify an existing UNIX user (e. Finally. provide the Samba user name. folder and file sharing is really easy. restart the Samba server again.xxx.If you have ticked the option Writable.conf. Browse to the shared folder. Very simple.conf /etc/cups/cupsd.g.xxx. The rougher side of the coin is accessing a printer installed on a Linux machine from a Windows machine. If you have a printer installed on a Windows machine. you will have to allow your printer to be shared. If the shared folder is writable. What about the printers? Again. the sharing itself. Linux > Windows Press Alt + F2. specify the IP address or the name of the computer that you wish to connect Printer sharing Well now. e. you will be able to modify the contents. Backup and then edit the Common UNIX Printer System configuration file. cp /etc/cups/cupds.conf . Now. Do not forget the apostrophes! You will be asked to create a password.g. And that's it. In the Command line. And finally.bak gedit /etc/cups/cupsd. This will bring up the Run Command window. it is very simple.First. roger). Windows > Linux Start > Run > \\xxx. accessing it from a Linux machine will be easy. roger and the relevant password. for the changes to take effect.

xxx:631 OR *:631 Listen /var/run/cups/cups. Worry not! Using generic drivers for Hewlett Packard printers will work remarkably well. Connect to a printer on the Internet or on a  home or office network .xxx.xxx.0.sock CUPS listens on the port 631.0..xxx... http://xxx.xxx. A network printer.1:631 OR localhost:631 xxx. Other useful commands .1:631 and add or change as follows: #Listen 127. so keep that in mind. you can specify only that IP. you will probably not be able to find the right Linux drivers for your printer. you should be aware that an open port means a wee less security than before.. you will have to restart CUPS: /etc/init. And that's it! You can now print from a Windows machine on a printer connected to a Linux machine.0. Otherwise. either select from a list or install it from a disk (like CD). search for the entry #Listen 127.. Of course..0. or a printer attached to  another computer .In the file. you will have to add it for the Windows machine. After saving the changes.. .. you might need to use a wildcard. Tip: If you are using a Lexmark printer. If you use a static IP address for the Linux machine.xxx:631/printers/printer_name OR http://netbios_name:631/printers/printer_name When prompted for the driver.d/cupsys restart Now that the printer is available. Start > Settings > Printers and Faxes File > Add Printer .

A variety of options (switches) can be used in conjunction with many of the commands to make their usage far more complex and effective. Be aware that the commands are presented in a generic way only.conf /etc/X11/xorg.bak Sometimes. Switching between runlevels init 0­6 OR telinit 0­6 Backing up the X Windows configuration file cp /etc/X11/xorg.conf. To display the CPU parameters: cat /proc/cpuinfo To display the memory parameters: cat /proc/meminfo To find the version of your kernel and the GCC compiler: cat /proc/version Furthermore. to find out the version of your kernel: . you may need or want to configure the X Windows manually: dpkg­reconfigure xserver­xorg Display system environment information You can use the cat (concatenate) command. which will print the contents of the files into the terminal.Here's a tiny sampling of some other useful tools that you might want to know.

your distro informs you that the process is already running.. The below command will terminate all processes with the corresponding name (or names). But this time. kill PID Alternatively. killall process_name Conclusion Well. you can kill a process by its name.uname ­r Listing information about files and folders This command is the equivalent of the DOS dir command. processes remain open and need to be killed.. Sometimes. only it does not really start. So you try again. . Before you can kill a process. ls ­a Kill a process Sometimes. ls To display hidden files as well (starting with dot). This can also happen in Windows. Hopefully you have learned something. for now. that's it. The command below will list all running processes: ps ­elf Then. you need to know its ID. you may start an application . kill the offending process by its ID.

. drivers. the above tips cover about 90% of tasks that a normal user would have to confront as a part of his/her daily usage. compilation from sources. this article may have helped you overcome some of the problems. and sharing. partitions. have fun tweaking. Isn't Linux so much fun? Well. Personally.If you have had problems with your software installations.