Академический Документы
Профессиональный Документы
Культура Документы
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.
Table of contents
1.
Basic tips
2.
Commands
1.
3.
1.
2.
Discipline
3.
Unpacking an archive
4.
Zipped archives
5.
Installation
6.
7.
4.
Installation of drivers
1.
Installation
2.
Loading drivers
3.
Configuration of drivers
4.
Scripts
5.
1.
Mounting a drive
Other options
6.
7.
Network sharing
1.
2.
8.
Printer sharing
9.
1.
2.
3.
4.
5.
Kill a process
Basic tips
There are some things you need to know before heading
into the deep waters of the Command Line:
Pressing TAB when typing a command will autocomplete the command. For example: if you have a single
file in a certain folder that begins with the letter p, typing
p then TAB will automatically complete the name
regardless of its length; if you have more than one file, 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).
Commands
Installation of software
Although most Linux distributions offer a wealth of useful
programs, you will probably be compelled to try new
Discipline
This may sound harsh or strict, but certain unspoken rules
are followed, which simplifies the use of software
downloads.
Unpacking an archive
The exact syntax will differ from one package to another.
But the general idea is the same for all. The only difference
will be in the arguments used for unpacking. Here are a few
common examples:
tarzxfsome_software.tar.gz
tarxjfsome_software.tar.bz2
You can read in detail about the handling of tarballs on
the Wikipedia site.
Zipped archives
Some archives will be zipped rather than tarred. This might
put you off. But the problem is easily solvable. If you recall,
we have the ability to "ask" for help for each unknown
command. In our case, we need to know how to unzip an
archive.
unziphelp
Installation
After unpacking the archive, you will now have to install the
software. Usually, the installation is invoked by using a
script. The exact name of the script will vary from one
program to another, as well as its extension, depending on
the language used to write it.
tarxjfsome_software.tar.bz2
cdsome_software_directory
./install_script
An archive containing sources:
tarzxfsome_software.tar.gz
OR
tarxjfsome_software.tar.bz2
cdsome_software_directory
./configure
make
makeinstall
Installation of drivers
Drivers are programs, like any software. The only difference
is - you do not actively use them. They serve the purpose of
making your hardware components understand each other.
As simple as that. You need them to enhance your usage of
the operating system.
Most often, the necessary drivers will be included with the
distribution and installed during the setup. Sometimes, you
might not be so lucky and will reach a newly installed
desktop without sound, network or video drivers.
I will not go into details explaining how specific drivers are
installed. You should contact your vendors for that
information. I will explain how to install the drivers, how to
Installation
Just like any software, drivers may be compiled or not. Most
often, they will not be. Drivers will usually be distributed as
sources, in order to achieve maximal possible compatibility
with the hardware on the installation platform. This means
you will have to compile from sources. Piece of cake. We
already know how to do that.
If the vendor is benevolent, it is possible that the driver will
be accompanied with a self-installation script. In other
words, you will need to run only one command, which will in
turn extract the archive, compile, install, and load it. But
this might not be the case - or might not even work. I have
personally witnessed a driver self-installation script go
wrong. Therefore, for all practical purposes, you should
probably manually install the driver.
After successfully extracting the archive and compiling the
sources (./configure, make, make install), you will most
likely be faced with three choices:
tarzxfsome_driver.tar.gz
OR
tarxjfsome_driver.tar.bz2
cdsome_driver_directory
./configure
make
makeinstall
Optional
./setup_driver_script
All that remains is to add this driver to the list of drivers
loaded at bootup. In Linux, the drivers are often referred to
as modules.
You need to open the configuration file containing the list of
modules. You should refer to your specific distribution for
exact name and location of this file. In Ubuntu, the file is
called modules.conf and is found in /etc directory
(/etc/modules.conf). We will update this file, but first we will
back it up! Please remember that you need root privileges to
meddle with the configuration files.
This is what our procedure would look like:
cp/etc/modules.conf/etc/modules.conf.bak
gedit/etc/modules.conf
The above commands will open the file modules.conf inside
the gedit text editor. Simply add your driver in an empty line
below the existing drivers, save the file, exit the text
Loading drivers
You have successfully compiled the driver, but nothing has
happened yet. This is because the driver is not yet enabled.
Looking inside the directory, you will notice a file with .ko
extension. This is your driver and you need to manually load
it.
Configuration of drivers
Configuring the driver requires a bit of knowledge into its
functionality. Most often, instructions will be included in the
how-to text files.
Below, the example demonstrates how the network card is
configured after the network driver is loaded. The network
card is assigned an identifier and an IP address. In this
particular case, eth0 was the selected device name,
although it could be also eth1, eth2 or any the name. The
assigned IP address tells us the machine will be part of a
LAN network.
ifconfigeth0192.168.0.9
After a reboot, you will realize that you no longer enjoy a
network connection. 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. You will have to repeat
the entire procedure again:
cddriver_directory
insmoddriver.ko
ifconfigeth0192.168.0.9
Scripts
Like in DOS and Windows, scripts can be written in any text
editor. However, special changes are needed to separate
between text files and scripts. In the Windows department,
simply renaming the .txt extension to .bat will convert the
file to a script. In Linux, things are a bit different.
Linux command line lives inside a shell - or more precisely
Shell. There are several Shells, each with a unique set of
commands. The most common (and default) Linux Shell is
theBASH. We need to add this information to our script, if
we wish to make it communicate with our Shell. Therefore,
the above commands + Shell addition will make the
following script:
#!/bin/bash
cddriver_directory
insmoddriver.ko
ifconfigeth0192.168.0.9
We can also make it shorter:
#!/bin/bash
insmod/home/roger/driver_directory/driver.ko
ifconfigeth0192.168.0.9
Now, we have a script. Or rather a text file that contains the
relevant commands. We need to make it into an executable
file. First, we need to save the file. Let's call
itnetwork_script. To make the script executable:
chmod+xnetwork_script
Now we have a real script. We need to place it in
the /etc/init.d directory so that it will be run during bootup.
cpnetwork_script/etc/init.d/
And finally, we need to update the system, so it will take our
script into consideration.
updaterc.dnetwork_scriptdefaults
After you reboot, you will realize that your driver loads
automatically and that your network card is
configured! Alternatively, it is possible that the make
install of the driver will place in the default directory:
/lib/modules/<KERNEL
VERSION>/kernel/drivers/net/driver.ko
Or you could place the driver in this directory by yourself.
This way, you will be able to avoid the step of writing the
script. However, my method, even if not the most elegant
one, has one advantage: Drivers that you have manually
compiled and placed into the default directories will be lost
every time you update the kernel. This means you will have
to reinstall them again after every such update. My method
un-elegantly escapes this problem.
Mounting a drive
If you run a dual-boot system, it is entirely possible that you
have installed your Linux before you have formatted all the
Windows drives. This means that some of these drives might
not be mounted - or accessible - when you're booted in
Linux. Alternatively, you might have formatted the drives,
but you have resized and relettered and renamed the
partitions and they are no longer recognized by Linux.
Furthermore, you just might be unlucky and your Linux
refuses to see the drives despite your best efforts. Finally,
you might be able to see them, but you cannot write to the
NTFS drives and this irks you so. Compared to the above
tasks, mounting drives is a simple job.
To be able to do this correctly, you need to know how your
drives are ordered and what they are called, both in
Windows and Linux. This requires that you be able to
Backup fstab.
mkdir/media/data
cp/etc/fstab/etc/fstab.bak
gedit/etc/fstab
After opening the file in the text editor, we need to add the
mount command. NTFS read-only:
/dev/hda2/media/datantfsnls=utf8,umask=022200
Other options
Alternatively, if you have partitions formatted with FAT32 file
system or you wish to be able to write to NTFS partitions
from within Linux, you can use the following commands:
FAT32 read/write:
/dev/hda2/media/datavfatiocharset=utf8,umask=000
00
NTFS read/write - requires installation of software that can
write to NTFS drives.
aptgetinstallntfs3g
/dev/hda1/media/datantfs3g
defaults,locale=en_US.utf800
/dev/hda1/media/windowsntfs3g
defaults,locale=en_US.utf800
/dev/hda2/media/datantfsnls=utf8,umask=022200
/dev/hda3/media/gamesvfat
iocharset=utf8,umask=00000
/etc/init.d/kdmstop
OR
/etc/init.d/xdmstop
The desktop should vanish and be replaced with a command
line. You will probably need to login. It is possible that you
will only see a black screen and no command prompt. Do
not be alarmed! Linux operating system usually has 7 virtual
consoles. The first six consoles provide a text terminal with
a login prompt to a UNIX shell. The 7th virtual console is
used to start the X Windows.
In other words, it may occur that by stopping the X
Windows you will have simply switched off the graphics AND
remain in the 7th virtual console, 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. Now, you need to install your driver:
shNVIDIA<DRIVERVERSION>.run
After the installation is complete, you should simply restart
the X Windows.
/etc/init.d/gdmstart
OR
/etc/init.d/kdmstart
OR
/etc/init.d/xdmstart
If you see an Nvidia splash logo, it means the driver has
been successfully installed. Reboot your machine just to
make sure. This is where you might encounter a problem.
Instead of the Nvidia logo, 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.conf file
before being able to proceed to the desktop. Now, there are
Again, you should see the Nvidia splash logo. Reboot just to
make sure there are no more surprises. This should get you
up and running with the latest graphic card driver.
Network sharing
If you have more than one computer, you are probably
sharing resources among them.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. Perhaps the simplest is using Samba server.
First, install Samba:
aptgetinstallsamba
After the Samba server is installed, you will need to edit a
few options in the configuration file to allow sharing
privileges.
cp/etc/samba/smb.conf/etc/samba/smb.conf.bak
gedit/etc/samba/smb.conf
In the configuration file, you will need to setup a number of
parameters:
security = user
Printer sharing
Well now, folder and file sharing is really easy. What about
the printers? Again, it is very simple. If you have a printer
installed on a Windows machine, accessing it from a Linux
machine will be easy. The rougher side of the coin is
accessing a printer installed on a Linux machine from a
Windows machine.First, you will have to allow your printer
to be shared. Backup and then edit the Common UNIX
Printer System configuration file.
cp/etc/cups/cupds.conf/etc/cups/cupsd.conf.bak
gedit/etc/cups/cupsd.conf
http://netbios_name:631/printers/printer_name
When prompted for the driver, either select from a list or
install it from a disk (like CD). And that's it! You can now
print from a Windows machine on a printer connected to a
Linux machine.
Tip: If you are using a Lexmark printer, you will probably not
be able to find the right Linux drivers for your printer. Worry
not! Using generic drivers for Hewlett Packard printers will
work remarkably well.
telinit06
unamer
Kill a process
Sometimes, you may start an application ... only it does not
really start. So you try again. But this time, your distro
informs you that the process is already running. This can
also happen in Windows. Sometimes, processes remain
open and need to be killed. Before you can kill a process,
you need to know its ID. The command below will list all
running processes:
pself
Then, kill the offending process by its ID.
killPID
Alternatively, you can kill a process by its name. The below
command will terminate all processes with the
corresponding name (or names).
killallprocess_name
Conclusion
Well, that's it, for now. Hopefully you have learned
something.