Sie sind auf Seite 1von 119

LINUX

In the early years of Linux, it's hard to get Linux installation done on the first try. This is usually because of hardware compatibility and driver support. During those days, choosing computer hardware and components are vital. It's very important to check for hardware compatibility lists in the Linux distribution's website before going shopping. However, due to the Linux reputation and popularity today, many computer manufacturers, even a well-known company provides pre-installation Linux in their product. A normal problem occurs during or after Linux installation would be the video card (video graphic adapter), network interface card (NIC), package installation problems, ide and sata drives and Xwindow system. That's the common problems. Other installation problems most certainly happen because user do not properly read or follow installation guide manual. If that's the case, please don't go in every Linux forum and ask for solution. The solution is very simple, start over, and this time please take it seriously, make proper preparations, read documentation, etc. Read previous topics: Introduction to Linux, Pre-installation checklist and Linux installation methods to have a basic ideas of what to be done. If you are lucky enough to have errors during installation (yes correct, it's "lucky"), then the first troubleshooting step you can take is check files below and you should find if there is an error in your system. View these files to troubleshoot your Linux installation problem. You will find that at the end of the day, the troubleshooting job makes you understand more about Linux system and how it works. /var/log/dmesg - Check hardware. /var/log/messages - Check Linux message log. /var/log/syslog - Check Linux system log.

Reconfigure Linux installation


The second Linux installation troubleshooting is to re-configure Linux installation. If you need to reconfigure your software or hardware, check this list: pkgtool - Software package maintenance tool. Install, remove or view packages. fdisk or cfdisk - Partitioning. /boot/grub/grub.conf - GRUB boot loader. /etc/lilo.conf - LiLo boot loader. netconfig - Networking (ethernet and tcp/ip) timeconfig - Time zone adduser - User accounts xorgsetup - Reconfigure X window system xorgconfig - Reconfigure mouse, keyboard, x window.

Linux important scripts location


Below are Slackware Linux important scripts location. If you are using different Linux distribution, you can find the script with find, whereis and locate commands.

Configuration and startup scripts /etc/inittab - run level setting script /etc/rc.d - startup script General purpose Linux network configuration scripts /etc/hosts - store hostname and IP address /etc/inetd.conf - execution information for on demand system services /etc/resolv.conf - contains DNS server addresses /etc/services - contains names and ports of network services /etc/nsswitch.conf - Sequences that the Linux system looks for the network services

Linux installation is not a big deal anymore nowadays. If you really cannot troubleshoot your Linux problems, you can search for solution in the Internet. There are millions of Linux users out there. Someone should have the same problem as yours before. Check out problem solution in your Linux distributions official forum. You can provide details of your problem and ask in the forum. There are many Linux experts out there who are willing to help.

Linux Basics Tutorial


Every Linux user should learn Linux basics and how Linux works before they can use Linux, as a desktop operating system or as a server. Linux is not very hard too learn. If you have experience using other operating system before, you probably have to spend some times to get used with Linux environment, depends on what operating system you have used. It is very important to learn the basics of Linux operating system. Although you can find a step by step tutorial on how to setup Linux server, for example, but without basic Linux knowledge, you won't be able to understand what you are doing. Spend some times to learn basics of Linux would save your times in the future.

Linux basics tutorials


You have learned some Linux basics knowledge during the hard disk partitioning and configure networking when setting up Linux installation. You probably have a basic idea about the Linux file system architecture now. After finished the Linux installation process, Linux is going to reboot to complete the installation. Slackware Linux or Ubuntu server first boot will land you in a command line terminal. Here is a guide on what to do next, Linux basics - First boot into Linux terminal. In Linux, there are six command line terminals by default. What is that means? Linux command line terminal also called virtual console. In windows, it's called command prompt. When Linux finished boot up, it'll prompt you to login at command line terminal. So you login into your Linux system. That's the Linux command line terminal one. There are five more Linux command line terminals that you can use independently in the system. Learn how you can use Linux terminals in Change Linux command line terminal tutorial. Now that your Linux is already up and running, you are ready to learn some basics Linux. Linux system startup process involves several important steps that Linux users need to know. This is vital in case of system boot up failure. By learning how Linux process start up, user can configure or at least know where to look for when troubleshooting a broken system. You can read about Linux system start up process in Linux basics - System startup process tutorial. Linux file system structure overview is an introduction to file system directory hierarchy in Linux system. A Linux beginner might get confuse between Linux file system structure and Linux filesystem types. File system structure is a Linux directory layout. Basically, there are 18 directories under / and every Linux user must have a basic knowledge on what each directory's purpose is. You can read more in Linux basics - Linux file system structure overview. After learning all tutorials above, you should have a basic knowledge about the basics of Linux operating system. The next phase of basics Linux tutorial is to learn Linux commands. Linux is not like windows. In Linux, we can set up any server using command line terminal but that's not the reason why we need to learn Linux commands. Linux command line terminal (Linux virtual console) is the first interface that lets user interacts with the operating system. User can troubleshoots a broken system, do operating system administrations, set up networking and everything else including prepare the graphical user interface, which is the x-window system. Because of that, learning basic Linux commands and essential programs in command line terminal is necessary.

When learning Linux commands, user actually learns a shell commands. A shell is an interface that interact with operating system kernel, in our case, the Linux itself. A Linux default shell is called Bourne Again Shell or Bash which is based on Bourne shell. There are other shells that can be used in Linux such as C shell, Korn shell, and Bourne shell. There is no need to master all Linux shells. The bash alone is enough. In reality, it takes months to master the bash commands. That's why the Linux commands has been put in a different category although learning Linux commands is considered basics Linux knowledge.

A. First Boot Into Linux Terminal


After finished the Linux installation process, Linux is going to reboot to complete the installation. Slackware or Ubuntu server Linux first boot will land you in a command line terminal.

First thing to do
Now that you have Linux installed in your computer, you might wonder what to do next. The most important thing now is to know our new operating system and learn a few basic commands. First, let's see what we got after we reboot the computer. If you installed a Linux desktop such as Ubuntu desktop, you'll get graphical user interface login screen similar like the one in Windows XP. But if you install a Slackware or Ubuntu server, then you'll boot into the Linux terminal. Now, let's see what we got before getting that login page. The first thing happened was Linux boot manager which is called a LILO (Linux Loader) if you use Slackware, some distributions use GRUB, appeared and greeted us with welcome message. We'll see a menu and a list of operating system in our system. If you installed a dual boot, then there'll be two operating systems in the menu. Don't worry if you didn't see any boot manager. Some system doesn't wait for user to select operating system if there is nothing to select, means you have only one operating system. Below is a screenshot example of a Slackware LILO menu: Select Linux with up/down key and press Enter to choose. Press Tab key if you need to enter boot parameter or login into single user mode.

First login
This tutorial example is using Slackware Linux. However it's the same if you use Ubuntu server. The startup process begins and finished at the login prompt. Now we are going to login into our new system. We have to provide a username at the login prompt. Most Linux distributions will asked to create a root user password during the installation process. Some distributions may not such as Ubuntu. That means you did create a user account but not the root user. So use that username to login into your system. If you use a Linux distribution which allow you to create root user such as Slackware, then you can login as root. Type 'root' or whatever your username is and press Enter. Now you have to enter your password. There is nothing appear as you type your password but it's there. That's the way Linux is. Don't worry if you got 'Login incorrect', repeat again and enter the correct password.

Example of Slackware login screen:


/lib/modules/2.4.29/kernel/drivers/char/agp/agpgart.o.gz: insmod agpgart failed scsi0 : SCSI host adapter emulation for IDE ATAPI devices Checking non-root filesystems: fsck 1.35 (28-Feb-2004) devpts on /dev/pts type devpts (rw,gid=5,mode=620) Using /etc/random-seed to initialize /dev/urandom. INIT: Entering runlevel: 3 Going multiuser... Starting sysklogd daemons: /usr/sbin/syslogd /usr/sbin/klogd -c 3 -x Activating hardware detection: /etc/rc.d/rc.hotplug start Starting Internet super-server daemon: /usr/sbin/inetd Starting OpenSSH SSH daemon: /usr/sbin/sshd Updating shared library links: /sbin/ldconfig Updating X font indexes: /usr/X11R6/bin/fc-cache Starting sendmail MTA daemon: /usr/sbin/sendmail -L sm-mta -bd -q25m Starting sendmail MSP queue runner: /usr/sbin/sendmail -L sm-msp-queue -Ac -q2m Starting gpm: /usr/sbin/gpm -m /dev/mouse -t imps2 gpm: oops() invoked from gpm.c(977) /dev/mouse: No such device Welcome to Linux 2.4.29 (tty1)

When you have successfully login into your account, you'll get a prompt like the picture below. There's a report of failure login you just did before and you have mail in your mailbox. Example of Slackware login failure :
Welcome to Linux 2.4.29 (tty1) hitam login: root Password: Login incorrect hitam login: root Password: Linux 2.4.29. 1 failure since last login. Last was 10:04:01 on tty1. Last login: Mon Jan 23 09:41:27 +0800 2006 on tty1. You have mail.

Logging out of Linux system


For now just forget about the mail. The first Linux basic command to use is logout. This command is use to log off from current session. It is a security practice to never leave your computer or server unlocked. To use logout command, just type 'logout' and press Enter. You can see the command issued in Slackware in the example below. Example of Slackware logout command:
hitam login: root Password: Linux 2.4.29. 1 failure since last login. Last was 10:04:01 on tty1. Last login: Mon Jan 23 09:41:27 +0800 2006 on tty1. You have mail. root@hitam:~# logout Welcome to Linux 2.4.29 (tty1)

The command exit also doing the same job. Another way to logout of Linux system is by using shortcut key. To use the short-cut key, hold Ctrl and press D on your keyboard.

Read mail in Linux


Login again. You wonder who sent you mail, right? Well, type'mail' and Enter. Enter to scroll down and read your mail.
Welcome to Linux 2.4.29 (tty1) hitam login: root Password: Linux 2.4.29. Last login: Mon Jan 23 10:04:10 +0800 2006 on tty1. You have mail. root@musang:~# mail Heirloom mailx version 12.3 7/15/07. Type ? for help. "/var/spool/mail/root": 2 messages >O 1 To root Wed Apr 23 14:16 the Linux counter project O 2 Patrick J. Volkerd Wed Apr 23 14:16 Linux (Slackware 12.1)! ? Interrupt ?

43/1593 Register with 345/16603 Welcome to

In Slackware linux, all users' emails are stored in the /var/spool/mail directory. If you have finished reading your mail, type 'q' to exit your mailbox. Enter.
If you installed the F series, there will be lots of FAQs (lists of Frequently Asked Questions with answers) /usr/doc/Linux-FAQs/, and HOWTOs (files explaining how to do a particular Linux task), in /usr/doc/Linux-HOWTOs/. These should be helpful in getting you going with Linux. They cover most system admin tasks in a lot more detail than this little email does. Also see the RELEASE_NOTES included with the distribution for any last-minute changes. Have fun! --Patrick Volkerding hisemailatslackware.com ? At EOF ? q Held 2 messages in /var/spool/mail/root

Shutdown Linux
If you really tired now, feel like sleeping already, then you have to learn this very important command called 'shutdown'. The shutdown command, like the name suggest, is to shut the system down. In other words, shutdown command is used to power off the computer. To use the command, type shutdown at the prompt and press Enter. Your Linux won't shutdown the system. Why? Depends on the system, if you are using Slackware, then the command syntax is not complete. What you see is a 'command info'. It tells us the command we typed was incomplete. This is a brief description on how to use the command. Example of Slackware shutdown command info:
root@hitam:~# shutdown Usage: shutdown [-akrhfnc] [-t secs] time [warning message] -a: use /etc/shutdown.allow -k: don't really shutdown, only warn. -r: reboot after shutdown. -h: halt after shutdown.

-f: do a 'fast' reboot (skip fsck). -F: Force fsck on reboot. -n: do not go through "init" but go down real fast. -c: cancel a running shutdown. -t secs: delay between warning and kill signal. ** the "time" argument is mandatory! (try "now") **

Referring to the information, the correct command to shutdown Linux is 'shutdown -h now'. If you are using Ubuntu, then you don't have root privilege to issue the shutdown command. Remember that you are login as a normal user? You need to add sudo command before shutdown. The complete syntax would be sudo shutdown -h now. Then you'll be prompt for password. Enter your password and your system will begin to shutdown.

How to get help in Linux


If you are ready to continue, let's try a few more commands after you login again. Because this is a new and fresh installation, we'll learn how to get help in Linux. If you have Internet connection all the times, then you can always go to the Linux distribution website or many useful Linux forums to ask for help. For those who hasn't got much times to access the Internet, don't worry because you can get help in the Linux itself. You can always check the 'manual' to better understand the command's options. For example, if you don't know how to use a 'useradd', type 'man useradd ' like the example below.
root@hitam:~# root@hitam:~# man useradd

When you press Enter, you'll get a page similar to this:


USERADD(8) NAME useradd - Create a new user or update default new user information SYNOPSIS useradd [-c comment] [-d home_dir] [-e expire_date] [-f inactive_time] [-g initial_group] [-G group[,...]] [-m [-k skeleton_dir]] [-o] [-p passwd] [-s shell] [-u uid] login useradd -D [-g default_group] [-b default_home] [-e default_expire_date] [-f default_inactive] [-s default_shell] DESCRIPTION Creating New Users When invoked without the -D option, the useradd command creates a new user account using the values specified on the command line and the default values from the system. The new user account will be entered into the system files as needed, the home directory will be created, and initial

Don't worry too much if you don't understand the manual completely. As time goes by, you'll get it. If you wan to learn more about man command, see the Linux man command tutorial.

Change Linux command line terminal


In Linux, there are six command line virtual terminals by default. What is that means? When Linux finished boot up, it'll prompt you to login at command line terminal. So you login into your Linux system. That's the Linux command line virtual terminal one. There are five more Linux command line virtual terminals that you can use independently in the Linux system.

Change virtual terminal in Linux


Let's login as root in the terminal one, if you are using Slackware Linux. On Ubuntu server, you can login as normal, use username that you choose during Linux installation. Now, press Ctrl-Alt-F2 combination keys to change terminal to the virtual terminal two. Login with the new user account. If you don't have a normal user account, create at least one account because you are going to use it in the administration section tutorials later. Check this tutorial on how to create a Linux user account.
Welcome to Linux 2.4.29 (tty2) slackware login: jadon Password: Linux 2.4.29. No mail. jadon@slackware:~$

Press Ctrl-Alt-F1 combination keys and you'll be back to the first virtual terminal where we first login as root (or whatever user you login with). You can use six virtual terminals with the same or different user at one time to do different task. I mean, you can download software packages in one terminal, playing mp3 in next terminal, and configure server in other terminal with completely independent, like using a different computer. To switch between virtual terminals, press Ctrl-Alt-(F1-F6). Now, that's multiuser and multitasking :-) Switch back to virtual terminal 2. Now that you know how to login and logout, create new users, using commands and get help, you are ready to explore more in the Linux world. In Linux, particularly Slackware Linux, all the commands located in /bin directory. Type cd /bin and enter. The command Linux cd command is use to change directory. You can learn more about Linux cd command in Linux cd command - explore Linux directory file system. Type ls to list the content in /bin directory. For more information about Linux ls command, you can visit Linux ls command - Listing directory content. Here is an example of Linux /bin directory:

Check and learn all the commands in /bin directory using man command-name. Note that in Linux and all Unix-based operating system, all commands are case sensitive. That means, if the command is mkdir, it's wrong if you type Mkdir or MKDIR and no space. You must type exactly as it is.

Change to Linux command line terminal from Linux desktop


If you are using Ubuntu desktop or other Linux distribution which login directly into kde or gnome, you can switch to Linux command line terminal using ctrl + alt + F1 keys combination. Once you are in the virtual terminal, use ctrl + alt + F2 to switch to terminal 2 and so on. You can also open Linux command prompt from the x-window itself. For example, if you are using Ubuntu desktop, you can open command prompt by clicking Applications, choose Accessories and click Terminal. Below is an example of command terminal opened from gnome Ubuntu desktop.

That's all.

B. System startup process


Linux system startup process involves several important steps that Linux users need to know. This is vital in case of system boot up failure. By learning how Linux process start up, user can configure or at least know where to look for when troubleshooting a broken system. When Linux system startup or bootup, init daemon (process) first read /etc/inittab file. Then, it runs /etc/rc.d/rc.S script. The program then will enable SWAP, mount file system, cleans up log directories, initializes PnP devices, load kernel modules and set up serial ports. After that, it runs 'Run level script' and 'Network Initialization', like the diagram below:
init (8) | read /etc/inittab (5) -----------> run <---------- /etc/rc.d/rc.S | Enable SWAP Mount file system Cleans up log directories Initializes PnP devices Load kernel modules Set up serial ports | Run level script rc.0 - Halt rc.4 - Multi user (X11) rc.6 - reboot rc.K - Single user (1) rc.M - (2,3)

Network Initialization rc.inet1 - netconfig rc.inet2 - basic network service rc.httpd - Apache rc.samba - Windows sharing

Slackware Linux /etc/inittab


This is an example of Slackware Linux /etc/inittab file.
# # inittab This file describes how the INIT process should set up

# # # # # # # # # # # # # # # # # #

the system in a certain run-level. Version: @(#)inittab 2.04 17/05/93 MvS 2.10 02/10/95 PV 3.00 02/06/1999 PV 4.00 04/10/2002 PV Author: Miquel van Smoorenburg, <miquels@drinkel.nl.mugnet.org> Modified by: Patrick J. Volkerding, <volkerdi@slackware.com> These are the default runlevels in Slackware: 0 = halt 1 = single user mode 2 = unused (but configured the same as runlevel 3) 3 = multiuser mode (default Slackware runlevel) 4 = X11 with KDM/GDM/XDM (session managers) 5 = unused (but configured the same as runlevel 3) 6 = reboot

# Default runlevel. (Do not set to 0 or 6) id:3:initdefault: # System initialization (runs when system boots). si:S:sysinit:/etc/rc.d/rc.S # Script to run when going single user (runlevel 1). su:1S:wait:/etc/rc.d/rc.K # Script to run when going multi user. rc:2345:wait:/etc/rc.d/rc.M # What to do at the "Three Finger Salute". # ca::ctrlaltdel:/sbin/shutdown -t5 -r now # Runlevel 0 halts the system. l0:0:wait:/etc/rc.d/rc.0 # Runlevel 6 reboots the system. l6:6:wait:/etc/rc.d/rc.6 # What to do when power fails. pf::powerfail:/sbin/genpowerfail start # If power is back, cancel the running shutdown. pg::powerokwait:/sbin/genpowerfail stop # These are the standard console login getties in multiuser mode: c1:1235:respawn:/sbin/agetty 38400 tty1 linux c2:1235:respawn:/sbin/agetty 38400 tty2 linux c3:1235:respawn:/sbin/agetty 38400 tty3 linux c4:1235:respawn:/sbin/agetty 38400 tty4 linux c5:1235:respawn:/sbin/agetty 38400 tty5 linux c6:12345:respawn:/sbin/agetty 38400 tty6 linux # Local serial lines: #s1:12345:respawn:/sbin/agetty -L ttyS0 9600 vt100 #s2:12345:respawn:/sbin/agetty -L ttyS1 9600 vt100 # Dialup lines: #d1:12345:respawn:/sbin/agetty -mt60 38400,19200,9600,2400,1200 ttyS0 vt100 #d2:12345:respawn:/sbin/agetty -mt60 38400,19200,9600,2400,1200 ttyS1 vt100 # Runlevel 4 used to be for an X window only system, until we discovered # that it throws init into a loop that keeps your load avg at least 1 all

# the time. Thus, there is now one getty opened on tty6. Hopefully no one # will notice. ;^) # It might not be bad to have one text console anyway, in case something # happens to X. x1:4:wait:/etc/rc.d/rc.4 # End of /etc/inittab id:3:initdefault: change to id:4:initdefault:

As you can see, Slackware linux run level is different from Fedora linux. If you want your slackware to boot directly into xwindow, use vi editor to change the default runlevel which is 3 to 4 (red font color): If you don't know how to use vi editor, here's a vi beginner tutorial just for you.

C. Linux vi editor tutorial


The vi editor has a long history in UNIX. It is a default text editor of the UNIX and UNIX based operating system including Linux. Some people say vi is difficult to use. Here is a good news for you, the improved version of Vi editor which is called Vim editor is a lot easier and user friendly. In this tutorial, I'll just mention Vi but it's the same as vim. I'll mention some vim improvements over original vi editor at the end of this tutorial.

Create new file with vi editor


In the Linux permission tutorial you have been introduced briefly to vi editor. You probably still remember that vi has 2 modes, command mode and insert mode. To start vi from the command line, type:
vi filename

or
vim filename

The vi command will create a new file if the filename you mention in the command above does not exist in the current directory. Youll have a screen with a column of tildes (~) on the left screen like the example below:.
luzar@slackware:~$ mkdir vitutorial luzar@slackware:~$ cd vitutorial/ luzar@slackware:~/vitutorial$ vi vitest

To insert text to the new file, press i. Now you can start typing what you want. You probably notice that delete key and backspace key didn't work. If you want to delete text, you must enter vi command mode. Press Esc to go the vi command mode. To delete a character, move cursor to the character and press x to delete that character. To delete a line, move cursor to the beginning of the line and press dd. To continue insert the text again, press i or this time try press a to append text. The different between i and a command in vi is, a will move the cursor one character after the current cursor. At this step in the learning process, just remember the vi command mode and vi insert mode. The vi command mode is everything here, insert text, delete text and save file. Oh we haven't save our file yet. To save and exit file, enter this key: :wq. Of course it's in the command mode.

You can find all basic vi commands in the next topic.

Edit file with vi editor


The Linux vi editor is a great tool to edit files in the Linux command line terminal. It has been a popular text editor to edit server configuration files and programs for so long. Almost all Linux distributions include vi editor in default installation. Now, let's learn how to edit file with vi editor. The syntax used to edit file using vi editor is the same as create a new file. To edit a file in Linux system, you can change directory or just provide the path to the directory where the file resides. See the vi format below: vi /path/to/filename During the create new file with vi editor practice, we didn't use much commands. You learn how to insert text, delete text and save file. However, when editing a file or program in Linux, you are going need more than that. Of course, the basic file editing is just insert text, delete text and save the changes, but there are many useful vi commands that can make your job a lot easier. This is the table of basic vi commands that you can use to assist you editing a file in Linux command line terminal:
Command i a u x dd yy p ZZ Description Insert text Append Undo Delete 1 character Delete one line Yank (copy 1 line) Paste Exit and save

:q :wq :q! :wq! / ? h j k l

Quit without saving Write and quit Force quit without saving Force write and quit Searches forward Searches backward Move cursor back 1 space Move cursor down 1 line Move cursor up 1 line Move cursor forward 1 space

Those are basic vi commands that every Linux user should remember. In the original vi editor, the arrow keys are not for moving cursor. You probably noticed that during create a new file with vi editor practice before. If you don't know how to move the cursor, then how do you plan to edit a file? Here is the tips on how I remember the keys to move cursor in vi editor. I just remember two keys, the key point, j for jump and the k for climb. Use j to jump down one line and k to climb up one line. Then I would know that before j is h which is used to move back one step and the l key in front is to move forward. I don't know what you think about that, but that's how I remember how to move cursor in vi text editor. Let's start practice editing a file with vi text editor now by openning the file that we created just now.
luzar@slackware:~/vitutorial$ vi vitest

This is the my vitest file. It doesn't matter if your file content doesn't similar with mine. We are going to try all those command above so you can see how it works and get familiar with it. You already use i to insert text before. This time, use a to append text to the file. Press a and type something.
Tdfgdfhis is a vi test file. We just learn how to insert text to new blank file. We open the file with: vi filename We save a file with: :wq in command mode.

When you open the file with vi editor, the cursor will be at the first character on the first line. When you press a to append text, the cursor will move to the next character, that means the second space. As you can see from the example above, I type something that I don't understand myself. So, I want to cancel it. What command that we have in vi editor which can cancel what we did? We can delete character like in the create new file example above. But there is a useful command in vi editor that we can use, which is the undo command. To undo, press Esc key to go to the vi command mode and press u. This will undo what I just type a moment ago.
This is a vi test file. We just learn how to insert text to new blank file. We open the file with: vi filename We save a file with: :wq in command mode.

We already know how to delete a character in vi editor, let's try delete one line. The vi command to delete one line is the dd command. When you press dd, the line which your cursor is at the moment will be deleted. To delete the line with dd, make sure you are in the vi command mode. See the example below:
We open the file with: vi filename We save a file with: :wq

in command mode.

As you can see, the first line is gone when I press dd. Press u to undo, and the line is back. The next command is the vi command to yank. Yank means copying one line. Press yy at the first line will copy that line. when we press p, vi will paste that line below the line where the cursor is right now. Let's see what it means:
This is a vi test file. We just learn how to insert text to new blank file. This is a vi test file. We just learn how to insert text to new blank file. We open the file with: vi filename We save a file with: :wq in command mode.

The cursor is at the first line when I press yy. So vi paste the line to the line below it when I press p. You already learn how to save and exit file in previous the example. If we don't want to save the file, we can enter the key :q which means just quit. But if we press :q now, vi won't quit. That is because we already make changes to the file. Vi warns us that the file has been modified, and we do not save it yet. We can see the message at the bottom of vi editor which says vitest modified, not saved. If we want to save, we can issue the :wq command or the ZZ (double upper case Z) command. If we don't want to save and just quit, we must force vi to quit. The command to force quit is :q!. One of the most useful utility that vi has is the / command, which can be used to search text in the file. We can use vi search utility to edit a certain word for the whole file. We can also use the vi search utility to fine a certain word in a large file without having to scroll line by line looking for the word. To use the vi editor search utility, type /word and enter. Vi will move the cursor to the first word in the file. To go to the next word, press n. You can press n again and vi editor will continue looking for the next word in the whole file. The vi / command searches forward, that means from top to bottom, and the ? command searches backward, opposite the /. Finally, we can move the cursor around in the file with j, k, h, l keys. Move down line by line to the end of the file by pressing j. To move up line by line, press k. Press j to move backward on the line. Press l to move forward on the line. What do you think of vi editor now? Is it difficult to use? I'm sure your answer is yes if you are a gui user before. Well, don't give up now. All you need is some practice. You'll never regret because vi editor is very useful and supported by most of unix-based operating system. There are many other things that you can do with vi. If you want to know what vi is capable of, type vimtutor and scan over to see what it can do. So, what are improvements vim over vi editor? Like I said earlier, it's more user friendly. For example, with vim editor, you can use backspace as well as delete key function. You can also use arrow keys. That improvement alone means so much for a beginner. Other vi editor basic functions are still the same. And I recommend vim for all Linux users. To use vim instead of vi, you just replace vi with vim. For example, if we want to edit a file, type vim file. That's all. Here is a description about vim from the manual page:
DESCRIPTION Vim is a text editor that is upwards compatible to Vi. It can be used to edit all kinds of plain text. It is especially useful for editing programs. There are a lot of enhancements above Vi: multi level undo, multi windows and buffers, syntax highlighting, command line editing, filename completion, on-line help, visual selection, etc.. See ":help vi_diff.txt" for a summary of the differences between Vim and Vi.

While running Vim a lot of help can be obtained from the on-line help system, with the ":help" command. See the ON-LINE HELP section below. Most often Vim is started to edit a single file with the command vim file More generally Vim is started with: vim [options] [filelist] If the filelist is missing, the editor will start with an empty buffer. Otherwise exactly one out of the following four may be used to choose one or more files to be edited.

D. Linux File System Structure Overview


Linux file system structure overview is an introduction to file system directory hierarchy in Linux system. A Linux beginner might get confuse between Linux file system structure and Linux filesystem type. Maybe you still remember during Linux hard disk partition process, we have to choose Linux filesystem type which includes ext2, ext3, reiserfs, etc. That's Linux filesystem type. What we are going to learn in this tutorial is Linux file system structure, a Linux directory structure that has been derived from Unix. In Windows operating system, we have C:\ drive, and there are many directories under C:\, such as Documents and Settings, Program Files, etc. In Linux, we can think of / (root directory) as C drive in Windows. All file system directory or mount points in Linux are under / directory. It maybe strange looking at Linux file system structure at first. There are many directories full of child directories and files. Some directories such as bin, sbin and lib can be found in several other directories too. Calm down. Actually, Linux file system is not so complicated as you might think. I already mentioned about root directory (/) which contains all other directories in Linux system. Now let's see it for ourselves. Please open Linux command line terminal. Change to / directory by typing 'cd /'. Type 'ls' to view the content. This is a Slackware Linux file system structure:
luzar@slackware:~$ cd / luzar@slackware:/$ ls bin/ dev/ home/ lost+found/ boot/ etc/ lib/ media/ luzar@slackware:/$

mnt/ opt/

proc/ root/

sbin/ srv/

sys/ tmp/

usr/ var/

This is Ubuntu Linux file system directory:


luzar@ubuntu:/$ cd / luzar@ubuntu:/$ ls bin cdrom etc initrd boot dev home initrd.img

lib lost+found

media mnt

opt proc

root sbin

srv sys

tmp usr

var vmlinuz

luzar@ubuntu:/$

You can see 18 directories under / in Slackware Linux and we have 19 directories and three links under / in Ubuntu. We won't be looking at each directory details at the moment. For now let's just look at the directory structure. In Linux, we use ls command to lists or views directory content. To view long listing of the content, type 'ls -l' and Enter. Example of Slackware Linux file system directory viewed using ls command long listing option:
luzar@slackware:/$ ls -l total 72 drwxr-xr-x 2 root root 4096 2007-04-30 12:35 bin/ drwxr-xr-x 2 root root 4096 2008-09-06 08:40 boot/ drwxr-xr-x 17 root root 14220 2008-11-01 16:55 dev/ drwxr-xr-x 65 root root 4096 2008-11-01 16:54 etc/ drwxr-xr-x 4 root root 4096 2008-11-01 16:54 home/ drwxr-xr-x 5 root root 4096 2008-03-12 11:47 lib/ drwx-----2 root root 16384 2008-09-06 08:19 lost+found/ drwxr-xr-x 16 root root 4096 2008-11-01 16:53 media/ drwxr-xr-x 11 root root 4096 2008-09-20 23:03 mnt/ drwxr-xr-x 2 root root 4096 2007-06-10 14:23 opt/ dr-xr-xr-x 107 root root 0 2008-11-02 00:52 proc/ drwxr-xr-x 11 root root 4096 2008-10-18 09:30 root/ drwxr-xr-x 2 root root 4096 2008-11-01 16:53 sbin/ drwxr-xr-x 2 root root 4096 2008-09-06 08:29 srv/ drwxr-xr-x 12 root root 0 2008-11-02 00:52 sys/ drwxrwxrwt 21 root root 4096 2008-11-01 16:56 tmp/ drwxr-xr-x 17 root root 4096 2006-11-09 04:10 usr/ drwxr-xr-x 17 root root 4096 2006-11-09 04:10 var/ luzar@slackware:/$

We can see details such as permissions, owner and date. Don't worry about any of these now. We are going to learn all of them later. Example of Ubuntu Linux directory structure:
luzar@ubuntu:/$ ls total 84 drwxr-xr-x 2 root drwxr-xr-x 3 root lrwxrwxrwx 1 root drwxr-xr-x 12 root drwxr-xr-x 81 root drwxr-xr-x 6 root drwxr-xr-x 2 root lrwxrwxrwx 1 root drwxr-xr-x 13 root drwx------ 2 root drwxr-xr-x 4 root drwxr-xr-x 3 root drwxr-xr-x 2 root dr-xr-xr-x 86 root drwxr-xr-x 3 root drwxr-xr-x 2 root drwxr-xr-x 2 root drwxr-xr-x 12 root drwxrwxrwt 3 root drwxr-xr-x 10 root drwxr-xr-x 14 root lrwxrwxrwx 1 root -l root 4096 2008-11-20 03:41 bin root 4096 2008-11-06 02:47 boot root 11 2008-10-20 10:44 cdrom -> media/cdrom root 13880 2008-12-03 21:46 dev root 4096 2008-12-03 22:15 etc root 4096 2008-10-24 00:07 home root 4096 2008-10-20 10:45 initrd root 32 2008-10-20 10:46 initrd.img -> boot/initrd.img-2.6.24-19-server root 12288 2008-11-20 03:41 lib root 16384 2008-10-20 10:44 lost+found root 4096 2008-10-20 10:44 media root 4096 2008-11-03 03:01 mnt root 4096 2008-10-20 10:45 opt root 0 2008-12-03 21:45 proc root 4096 2008-10-20 06:05 root root 4096 2008-11-20 03:41 sbin root 4096 2008-10-20 10:45 srv root 0 2008-12-03 21:45 sys root 4096 2008-12-03 21:46 tmp root 4096 2008-10-20 10:45 usr root 4096 2008-10-20 10:55 var root 29 2008-10-20 10:46 vmlinuz -> boot/vmlinuz-2.6.24-19-server

luzar@ubuntu:/$

If we want to draw a directory tree or Linux directory structure of the Linux file system hierarchy, it looks like this:

Some file system and directories structure in one Linux distribution maybe different from other Linux distributions as you can see from Slackware and Ubuntu example above. Right now you don't have to remember all of those directories and what they do. Just remember a few important directories first such as: / - root of all directories in Linux file system structure. /home - Keeps Linux user account's home directory. /etc - keeps Linux server's configuration files and directories. /usr - keeps Linux system files. /var - keeps system log files. /bin - keeps binary files for user applications. /sbin - keeps static binary files for system programs.

The / (root) directory is the most important directory in Linux file system structure. As you can see from the example above, / is the root of all directories in Linux system. The / is the parent of Linux file system structure. The /home directory keeps all Linux user account's home directory. Some Linux distributions keep FTP server home directory by default in /home directory. Make sure you provide big enough hard disk for /home directory. It's a good idea to set quota for each user account in /home directory. The /etc directory keeps all servers and application system's configuration files. This directory perhaps the most visited directory if you are working in Linux command line terminal. We've already seen the / directory structure in Linux file system. Next, we are going to view the /home directory. Below is the example of Slackware Linux /home directory:
jinlusuh@slackware:~$ ls /home/ ftp/ jinlusuh/ lost+found/ jinlusuh@slackware:~$

The example above shows an ftp directory, a normal user's home directory (jinlusuh) and a lost+found directory when we listing the /home directory. The Slackware server above is a Squid proxy server. If you view the /home directory of an Email Server, the directory will be full with users' home directories. Basically, that's all /home directory in Linux means. Perhaps the most important directory in Linux is the /etc directory. Let's see what we have in /etc directory. Here is an example of Linux directory structure of Ubuntu /etc directory:
luzar@ubuntu:~$ cd /etc luzar@ubuntu:/etc$ ls -d */ alternatives/ depmod.d/ apache2/ dhcp3/ modprobe.d/ Muttrc.d/ rc6.d/ rcS.d/

apm/ apparmor/ apparmor.d/ apt/ bash_completion.d/ belocs/ bind/ calendar/ chatscripts/ console-setup/ console-tools/ cron.d/ cron.daily/ cron.hourly/ cron.monthly/ cron.weekly/ cups/ dbus-1/ default/ defoma/ luzar@ubuntu:/etc$

dictionaries-common/ dovecot/ dpkg/ emacs/ event.d/ fonts/ foomatic/ groff/ grub.d/ hp/ init.d/ initramfs-tools/ iproute2/ john/ ldap/ ld.so.conf.d/ libpaper.d/ logcheck/ logrotate.d/ lsb-base/

mysql/ network/ openoffice/ opt/ pam.d/ pcmcia/ perl/ php5/ postfix/ ppp/ prelude/ profile.d/ python/ python2.5/ rc0.d/ rc1.d/ rc2.d/ rc3.d/ rc4.d/ rc5.d/

resolvconf/ samba/ sane.d/ security/ skel/ snort/ ssh/ ssl/ subversion/ terminfo/ udev/ ufw/ update-manager/ vim/ w3m/ whereami/ wpa_supplicant/ X11/

As mentioned before, the /etc directory holds configuration files of servers, applications, programming languages, network tools and many more. We can see from the example above, apache2, dhcp3, and samba are directory of the servers and calendar and emacs are applications directory. When listing directory content in Linux system, other than directories, there are normal files, executable files and symbolic links. How to differentiate each of them?The subject in blue color is a directory. It always mark with a '/' as in the example above. Sometimes you'll find a subject in green, light blue and white color. The green subject (mark with *) is an executable file. The light blue subject (mark with @) is a symbolic link and the white subject is a file. Type 'cd /etc/rc.d' and Enter. Type 'ls' to view the content.
luzar@slackware:/usr$ cd /etc/rc.d/ luzar@slackware:/etc/rc.d$ ls init.d/ rc.bluetooth rc.inet2* rc.0@ rc.bluetooth.conf rc.inetd* rc.4* rc.cups rc.ip_forward rc.6* rc.dnsmasq rc.local* rc.K* rc.font.new* rc.messagebus* rc.M* rc.fuse* rc.modules@ rc.S* rc.gpm* rc.modules-2.6.24.5* rc.acpid* rc.hald* rc.modules-2.6.24.5-smp* rc.alsa* rc.httpd rc.mysqld rc.atalk rc.inet1* rc.nfsd rc.bind rc.inet1.conf rc.ntpd luzar@slackware:/etc/rc.d$

rc.pcmcia rc.rpc rc.samba rc.saslauthd rc.sendmail rc.serial rc.snmpd rc.sshd* rc.syslog* rc.sysvinit* rc.udev*

rc.wireless* rc.wireless.conf rc.yp* rc0.d/ rc1.d/ rc2.d/ rc3.d/ rc4.d/ rc5.d/ rc6.d/

Here is the screenshot:

These are example of files (white), symbolic link (light blue@) and executable files (green*). For your information, those files above are 'daemons'. You'll play with them a lot soon. So remember the location. Type 'pwd' to check your current working directory and change your directory back to '/' by issue the command 'cd /'.
luzar@slackware:/etc/rc.d$ pwd /etc/rc.d luzar@slackware:/etc/rc.d$ cd / luzar@slackware:/$ ls bin/ dev/ home/ lost+found/ boot/ etc/ lib/ media/ luzar@slackware:/$

mnt/ opt/

proc/ root/

sbin/ srv/

sys/ tmp/

usr/ var/

Now we are back to the / directory. Let's view other directories to see what actually is the Linux directory structure. Now, change directory to /usr directory. View the content with 'ls -l'.
luzar@slackware:/$ cd /usr luzar@slackware:/usr$ ls -l total 348 lrwxrwxrwx 1 root root 5 drwxr-xr-x 2 root root 4096 drwxr-xr-x 2 root root 4096 lrwxrwxrwx 1 root root 8 drwxr-xr-x 2 root root 81920 drwxr-xr-x 2 root root 4096 drwxr-xr-x 570 root root 20480 drwxr-xr-x 4 root root 4096 drwxr-xr-x 249 root root 49152 drwxr-xr-x 2 root root 12288 drwxr-xr-x 103 root root 135168 drwxr-xr-x 15 root root 4096 drwxr-xr-x 11 root root 4096 drwxr-xr-x 45 root root 4096 drwxr-xr-x 2 root root 12288 drwxr-xr-x 158 root root 4096 lrwxrwxrwx 1 root root 10 drwxr-xr-x 4 root root 4096 lrwxrwxrwx 1 root root 8 luzar@slackware:/usr$

2008-09-06 2008-09-06 2008-09-06 2008-09-06 2008-11-01 1993-11-26 2008-05-01 2007-06-24 2008-09-20 2007-02-22 2008-11-01 2008-01-10 1994-03-16 2006-11-09 2008-11-01 2008-04-14 2008-09-06 2008-09-06 2008-09-06

08:32 08:32 08:21 08:21 16:53 11:40 08:10 14:57 23:03 05:58 16:53 01:39 09:50 04:10 16:53 13:28 08:21 08:25 08:21

X11 -> X11R6/ X11R6/ X11R6.bak/ adm -> /var/adm/ bin/ dict/ doc/ i486-slackware-linux/ include/ info/ lib/ libexec/ local/ man/ sbin/ share/ spool -> /var/spool/ src/ tmp -> /var/tmp/

In Slackware, this is the place where the Linux installation files are stored. You can type 'cd ..' to return to upper directory. That's all for now.

E. File System Types


If you read previous article, Linux basics - Linux file system structure overview, you should know the different between Linux file system and Linux filesystem. In this tutorial, we are going look at some Linux filesystems such as ext, ext2, ext3, Reiserfsand and other filesystems that Linux supports such as msdos, umsdos, vfat, proc, nfs, iso9660, hpfs, sysv, smb, ncpfs. We can view Linux user's manual using man fs command in the command line terminal or virtual terminal console. Here is the complete user's manual page open from Ubuntu:
minix is the filesystem used in the Minix operating system, the first to run under Linux. It has a number of shortcomings: a 64MB partition size limit, short filenames, a single timestamp, etc. It remains useful for floppies and RAM disks. is an elaborate extension of the minix filesystem. It has been completely superseded by the second version of the extended filesystem (ext2) and has been removed from the kernel (in 2.1.21). is the high performance disk filesystem used by Linux for fixed disks as well as removable media. The second extended filesystem was designed as an extension of the extended file system (ext). ext2 offers the best performance (in terms of speed and CPU usage) of the filesystems supported under Linux. is a journaling version of the ext2 filesystem. back and forth between ext2 and ext3. It is easy to switch

ext

ext2

ext3 Reiserfs XFS JFS xiafs

is a journaling filesystem, designed by Hans Reiser, that was integrated into Linux in kernel 2.4.1. is a journaling filesystem, developed into Linux in kernel 2.4.20. is a journaling filesystem, into Linux in kernel 2.4.24. by SGI, that was integrated

developed

by IBM, that was integrated

was designed and implemented to be a stable, safe filesystem by extending the Minix filesystem code. It provides the basic most requested features without undue complexity. The xia filesystem is no longer actively developed or maintained. It was removed from the kernel in 2.1.21. is the filesystem used by DOS, Windows, and some OS/2 computers. msdos filenames can be no longer than 8 characters, followed by an optional period and 3 character extension. is an extended DOS filesystem used by Linux. It adds capability for long filenames, UID/GID, POSIX permissions, and special files (devices, named pipes, etc.) under the DOS filesystem, without sacrificing compatibility with DOS. is an extended DOS filesystem used by Microsoft Windows95 and Windows NT. VFAT adds the capability to use long filenames under the MSDOS filesystem. is a pseudo filesystem which is used as an interface to kernel structures rather t han reading and interpreting /dev/kmem. In particular, its files do not take disk space. is a CD-ROM filesystem type data

msdos

umsdos

vfat

proc

See proc(5). iso9660

conforming to the ISO 9660 tandard.

High Sierra Linux supports High Sierra, the precursor to the ISO 9660 standard for CD-ROM filesystems. It is automatically recognized within the iso9660 file-system support under Linux. Rock Ridge Linux also supports the System Use Sharing Protocol ecords specified by the Rock Ridge Interchange Protocol. They are used to further describe the files in the iso9660 filesystem to a Unix host, and provide information such as long filenames, UID/GID, POSIX permissions, and devices. It is automatically recognized within the iso9660 file-system support under Linux. hpfs sysv nfs smb is the High Performance Filesystem, used in OS/2. This file system read-only under Linux due to the lack of available documentation. is an implementation of the SystemV/Coherent filesystem for Linux. implements all of Xenix FS, SystemV/386 FS, and Coherent FS. is the network filesystem used to access computers. disks located on remote is It

is a network filesystem that supports the SMB protocol, used by Windows for Workgroups, Windows NT, and Lan Manager. To use smb fs, you need a special mount program, which can be found the ksmbfs package, found at ftp://sunsite.unc.edu/pub/Linux/system/Filesystems/smbfs. in

ncpfs

is a network filesystem that supports the NCP protocol, used by Novell NetWare. To use ncpfs, you need special programs, which can be found at ftp://linux01.gwdg.de/pub/ncpfs.

You can build a Linux filesystem on a partition using the mkfs command. However, if you are planning to setup the whole hard disk drive, using the fdisk command is a lot easier. You can find fdisk guide in the Slackware hard disk partition with fdisk tutorial. The filesystem has to be mounted before you can use it in the Linux system.

Linux commands
Linux basic commands tutorial
Basic Linux commands and essential programs
You have learned some Linux commands such as logout, reboot and shutdown commands in the previous section. Those are the most basic Linux commands a user needs to know in order to use Linux. In this tutorial, you are going to learn some more Linux basic commands and essential Linux programs to help you explore your Linux system. Linux distribution such as Ubuntu has developed a desktop Linux, which includes almost all graphical tools needed to configure Linux applications in x-window. That means, new Linux user doesn't need to learn Linux commands to start using Linux. However, the fact that Linux is a multi-user and multitasking operating system means learning Linux commands let user to take full advantage of Linux potentials. The x-window such as KDE or GNOME is just another application in Linux. If something goes wrong, you need to switch to the Linux command line terminal to troubleshoot the problem. Ask all Linux users, they would certainly recommend learning Linux commands, at least some basic commands in Linux. The first Linux basic command you are going to learn is man command. The man command is a command to display manual or documentation included in the Linux system. It is the most useful command in Linux that will help you use and understand other commands available in the system. You can find more information about man command in Linux man command basic tutorial which was written for a Linux beginner. In the beginning, many people restrain to use Linux and one of the reason is they afraid because Linux is a free operating system and doesn't come with warranty and customer's support. Although most people aware that Linux works great with its big potential but that reason seems strong enough to hold them back. Actually, Linux comes with many great helping tools. We can't say Linux doesn't need customer's support at all but one thing to consider, Linux is the operating system that teach its users. It provides information and helps that user needs within the Linux operating system itself. What I mean is, Linux comes with great tools that user can always refer to whenever they need it. One of the most useful tool to get help in Linux system is the Linux online manual pages.

Linux manual pages


Linux manual page is a great help that comes together with Linux operating system. User can access Linux manual page by invoking man command at the command line interface. Linux man command formats and displays the online Linux manual pages. The Linux manual has 8 standard sections which are: 1. User Commands 2. System Calls 3. C Library Functions

4. 5. 6. 7. 8.

Devices and Special Files File Formats and Conventions Games et. Al. Miscellanea System Administration tools and Deamons

Linux distributions customize the manual section to their specifics, which often include additional sections.
SYNOPSIS man [-acdfFhkKtwW] [--path] [-m system] [-p string] [-C config_file] [-M pathlist] [-P pager] [-B browser] [-H htmlpager] [-S section_list] [section] name ... DESCRIPTION man formats and displays the on-line manual pages. If you specify section, man only looks in that section of the manual. name is normally the name of the manual page, which is typically the name of a command, function, or file. However, if name contains a slash (/) then man interprets it as a file specification, so that you can do man ./foo.5 or even man /cd/foo/bar.1.gz. See below for a description of where man files. looks for the manual page

As you can see, Linux man command offers several options for user to specify the details such as provides a specific path, search in specific manual database sections and displays the output in different format. It can also be as simple as it can be, for an example, if you want to just print help on the monitor's screen, then, issue:
luzar@slackware:~$ man man

That will print the manual page for Linux man command on the screen. You'll see a result similar to the picture below:

If you perhaps want to copy the man page to a specific file and print the hard copy to read it later, then the command should be:
luzar@slackware:~$ man man | col -b > /luzar/manual.txt

The | is called pipe and the key location is on the left of the backspace key on your keyboard. The col -b option is to get a plain text version without backspaces and underscores

The > is called redirection and it means please write in this file I mention here. The /luzar/manual.txt is the path and the name of the file. With Linux man command, we can view other commands available in Linux system to learn about that command. Let's say we need help on ls command, we just type man ls and enter:
luzar@slackware:~$ man ls

In Linux manual page about Linux commands, we can find 3 important information:
NAME - Shows the name of the command and a brief information about what it does. SYNOPSIS - Shows the command's syntax and available options that can be used with the command. DESCRIPTION - Explains more about the command. OPTIONS - Available options that can be used with the command. Some commands required option while some can be used with no option. Options enable user to customize the command, change the scope of default value the command offers, and many more depends on the command. TIPS or EXAMPLES - Some commands provide tips and usage examples. AUTHOR - Name of person who writes the command and his email address. (Thank you sir!) SEE ALSO - Related commands.

Here is more information about options available for Linux man command:
man, version 1.6f usage: man [-adfhktwW] [section] [-M path] [-P pager] [-S list] [-m system] [-p string] name ... a c d D f h k K t w find all matching entries do not use cat file print gobs of debugging information as for -d, but also display the pages same as whatis(1) print this help message same as apropos(1) search for a string in all pages use troff to format pages for printing print location of man page(s) that would be displayed (if no name given: print directories that would be searched) W : as for -w, but display filenames only C M P S m p file path pager list system string : : : : : : use `file' as configuration file set search path for manual pages to `path' use program `pager' to display pages colon separated section list search for alternate system's man pages string tells which preprocessors to run e - [n]eqn(1) p - pic(1) t - tbl(1) g - grap(1) r - refer(1) v - vgrind(1) : : : : : : : : : :

Linux man command examples


You can see some of man command's options which normally used to customize the result in all the examples below. Linux man command with -a option prints all matching entry:
luzar@slackware:~$ man -a man

MAN(1) NAME

Manual pager utils man - an interface to the on-line reference manuals

MAN(1)

SYNOPSIS man [-c|-w|-tZ] [-H[browser]] [-T[device]] [-X[dpi]] [-adhu7V] [-i|-I] [-m system[,...]] [-L locale] [-p string] [-C file] [-M path] [-P pager] [-r prompt] [-S list] [-e extension] [--warnings [warnings]] [[section] page ...] ... man -l [-7] [-tZ] [-H[browser]] [-T[device]] [-X[dpi]] [-p string] [-P pager] [-r prompt] [--warnings[warnings]] file ... man -k [apropos options] regexp ... man -f [whatis options] page ... DESCRIPTION man is the systems manual pager. Each page argument given to man is normally the name of a program, utility or function. The manual page associated with each of these arguments is then found and displayed. A section, if provided, will direct man to look only in that section of the manual. The default action is to search in all of the available sections, following a pre-defined order and to show only the first page found, even if page exists in several sections.

The example above is the first man result. To see the next manual page, press q to quit the current man. You'll get the menu like in the example below:
luzar@slackware:~$ man -a man --Man-- next: man(7) [ view (return) | skip (Ctrl-D) | quit (Ctrl-C) ]

Press enter or return key to view next man result. You can skip the result by pressing ctrl+D. Press ctrl+C to quit. If you press enter, you'll get the next man result like the example below:
MAN(7) NAME man - macros to format man pages SYNOPSIS groff -Tascii -man file ... groff -Tps -man file ... man [section] title DESCRIPTION This manual page explains the groff an.tmac macro package (often called the man macro package). This macro package should be used by developers when writing or porting man pages for Linux. It is fairly compatible with other versions of this macro package, so porting man pages should not be a major problem (exceptions include the NET-2 BSD release, which uses a totally different macro package called mdoc; see mdoc(7)). Linux Programmers Manual MAN(7)

That's another result of man command with -a option. Press q to quit the manual page. This is the example of man command with -k option which can be used to search the short descriptions and manual page names for the keyword mention as regular expression.
luzar@slackware:~$ man -k mkdir mkdir (1) - make directories luzar@slackware:~$

The man command with -f option can be used to lookup the manual pages referenced by keyword

mentioned and print out the short descriptions of any found. See the example below:
luzar@slackware:~$ man -f less less (1) - opposite of more luzar@slackware:~$

That all. Perhaps that covers almost all important information you need to know about Linux man command. Linux has many commands and it's impossible to remember all the commands' options. So, use man command to learn more about new Linux commands everyday The second Linux basic command which every Linux beginner should know is the uname command. The uname command prints information about Linux system. This command is really useful when we are checking our Linux system's kernel version, name, etc. See more information and examples of uname command in Linux uname command tutorial.

Linux uname command


Linux uname command is used to print information about Linux system. It is a simple command and you'll not use it everyday. However, uname command is useful when you need to know information about a new system or when you are doing routine maintenance for your Linux system. Below are some information from the uname manual page:
NAME uname - print system information SYNOPSIS uname [OPTION]... DESCRIPTION Print certain system information. With no OPTION, same as -s.

Linux uname examples


Example 1 - Use Linux uname command with no option:
luzar@musang:~$ uname Linux luzar@musang:~$

The uname command with no option prints operating system name. Example 2 - Linux uname command with -r option:
luzar@musang:~$ uname -r 2.6.24.5-smp luzar@musang:~$ The uname command with

-r option prints the kernel release.

Example 3 - Linux uname command with -v option:


luzar@musang:~$ uname -v #2 SMP Wed Apr 30 13:41:38 CDT 2008 luzar@musang:~$

The uname command with -v option prints the kernel version. Example 4 - Linux uname command with -p option:
luzar@musang:~$ uname -p Intel(R) Core(TM)2 Duo CPU luzar@musang:~$ E6750 @ 2.66GHz

The uname command with -p option prints the processor type. Example 5 - Linux uname command with -a option:
luzar@musang:~$ uname -a Linux musang 2.6.24.5-smp #2 SMP Wed Apr 30 13:41:38 CDT 2008 i686 Intel(R) Core(TM)2 Duo CPU E6750 @ 2.66GHz GenuineIntel GNU/Linux luzar@musang:~$

The uname command with -a option prints the kernel name, network node, kernel release, kernel version, machine hardware name, processor type, hardware platform and operating system. Another useful Linux basic command is the Linux env command. The env command let us check, add and modify a Linux user's working environment such as shell, path, mail and so on. These are basic things you should know about your Linux system. See more information about env command in Linux environment variables tutorial. Linux environment variables are settings for user's terminal environment, such as system path, application setting, and default shell. Setting Linux environment is like setting your workplace. It can greatly improve your work. You can customize Linux environment and set almost everything in your Linux system to be the way you want.

Linux env command


The Linux env command is used to manage Linux system environment. Invoking env command with no option will print environment variables for the current user. Here is an example of env command invoke by the first user in Ubuntu system.
luzar@ubuntu:~$ env TERM=xterm SHELL=/bin/bash SSH_CLIENT=192.168.44.1 4019 22 SSH_TTY=/dev/pts/0 USER=luzar LS_COLORS=no=00:fi=00:di=01;34:ln=01;36:pi=40;33:so=01;35:do=01;35:bd=40;33;01:cd=40;33;01:o r=40;31;01: su=37;41:sg=30;43:tw=30;42:ow=34;42:st=37;44:ex=01;32:*.tar=01;31:*.tgz=01;31:*.svgz=01;31:* .arj=01;31: *.taz=01;31:*.lzh=01;31:*.lzma=01;31:*.zip=01;31:*.z=01;31:*.Z=01;31:*.dz=01;31:*.gz=01;31:* .bz2=01;31: *.bz=01;31:*.tbz2=01;31:*.tz=01;31:*.deb=01;31:*.rpm=01;31:*.jar=01;31:*.rar=01;31:*.ace=01; 31:*.zoo=01;31: *.cpio=01;31:*.7z=01;31:*.rz=01;31:*.jpg=01;35:*.jpeg=01;35:*.gif=01;35:*.bmp=01;35:*.pbm=01 ;35:*.pgm=01;35: *.ppm=01;35:*.tga=01;35:*.xbm=01;35:*.xpm=01;35:*.tif=01;35:*.tiff=01;35:*.png=01;35:*.svg=0 1;35:*.mng=01;35: *.pcx=01;35:*.mov=01;35:*.mpg=01;35:*.mpeg=01;35:*.m2v=01;35:*.mkv=01;35:*.ogm=01;35:*.mp4=0 1;35:*.m4v=01;35: *.mp4v=01;35:*.vob=01;35:*.qt=01;35:*.nuv=01;35:*.wmv=01;35:*.asf=01;35:*.rm=01;35:*.rmvb=01 ;35:*.flc=01;35: *.avi=01;35:*.fli=01; 35:*.gl=01;35:*.dl=01 ; 35:*.xcf=01;35:*.xwd=01;35:*.yuv=01;35:*.aac=00;36:*.au=00;36:

*.flac=00;36:*.mid=00;36:*.midi=00;36:*.mka=00;36:*.mp3=00;36:*.mpc=00;36:*.ogg=00;36:*.ra= 00;36:*.wav=00;36: MAIL=/var/mail/luzar PATH=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games PWD=/home/luzar LANG=en_US.UTF-8 HISTCONTROL=ignoreboth SHLVL=1 HOME=/home/luzar LOGNAME=luzar SSH_CONNECTION=192.168.44.1 4019 192.168.44.128 22 LESSOPEN=| /usr/bin/lesspipe %s LESSCLOSE=/usr/bin/lesspipe %s %s _=/usr/bin/env luzar@ubuntu:~$

As you can see from the example above, the Linux env format is set like `VARIABLE=VALUE', where the environment variable VARIABLE is set to value VALUE. The VALUE may be empty (`VARIABLE='). Setting a variable to an empty value is different from unsetting it. A variable is evaluate from left-to-right, so if two same variables are mentioned, the earlier variable is ignored. The first operand that does not contain the character `=' specifies the program to invoke; it is searched for according to the `PATH' environment variable.
luzar@ubuntu:~$ env --help Usage: env [OPTION]... [-] [NAME=VALUE]... [COMMAND [ARG]...] Set each NAME to VALUE in the environment and run COMMAND. -i, --ignore-environment start with an empty environment -u, --unset=NAME remove variable from the environment --help display this help and exit --version output version information and exit A mere - implies -i. Report bugs to . luzar@ubuntu:~$ If no COMMAND, print the resulting environment.

If you need more information about Linux environment variables, a complete Linux env tutorial is available in your Linux system. You can view it by invoking info coreutils env invocation in the command line terminal like the example below:
luzar@ubuntu:~$ info coreutils env invocation

Linux command line interface is not about typing everything all around. If you are lucky to have seen a Linux guru doing his job in Linux command line interface, then you probably think that he's not from this world. Is he typing that fast? Moving between terminals, pressing keys, you can't barely seen what it is. Wow... Here I'm going to reveal their secrets so you too can look like a guru and perhaps be one in the future. The secret number one is called Linux history. Linux keeps all your running command in a file called .history. Check this basic Linux tutorial about bash history and learn how you can re-used previous command you typed in Linux command line terminal.

Linux history command


Linux bash history keeps every command a user typed in the command line terminal into a file named .bash_history. What good about this is that user can re-used the command in case they are lazy to type a very long argument presented with the command. It also faster to use bash command history rather than typing the same command all over again. That makes working in Linux command line virtual terminal a bit fun. Here is a description from the bash history manual page:
DESCRIPTION Many programs read input from the user a line at a time. The GNU History library is able to keep track of those lines, associate arbitrary data with each line, and utilize information from previous lines in composing new ones.

Linux bash history command examples


Linux bash history com mand available in all Linux distributions including Slackware Linux and Ubuntu server. What you need to do to view previously typed commands is just invoke history from Linux command prompt. Here is an example of Linux history command with no option running in Ubuntu server system command line terminal:
luzar@ubuntu:~$ history 1 ping 10.21.35.160 2 clear 3 ping -c6 10.21.35.160 4 ping -c3 10.21.35.160 5 ifconfig 6 ping -c3 10.21.35.160 7 route ---help 8 man route 9 route 10 history

In the example above, number 1 is the oldest command and number 10 is the latest command that a current user has typed. If you never clear the history file, you might see hundreds of commands that you typed including the latest 'history'. The bash history command would print only the latest page of the command history. However you can view bash commands history from the first page with pipe, like an example below:
luzar@ubuntu:~$ history | less

Let's see another example of bash history options. You can also use event designators to run command in the history using the ! key. See an example below:
luzar@ubuntu:~$ !8 man route luzar@ubuntu:~$

The example above run number 8 command in the history file, which is the man route command. Here is a complete options available with event designators:
Event Designators An event designator is a reference to a command line entry in the history list.

! Start a history substitution, except when followed by a blank,newline,= or (. !n Refer to command line n. !-n Refer to the current command line minus n. !! Refer to the previous command. This is a synonym for !-1. !string Refer to the most recent command starting with string. !?string[?] Refer to the most recent command containing string. The trailing ? may be omitted if string is followed immediately by a new line. ^string1^string2^ Quick substitution. Repeat the last command, replacing string1 with string2. Equivalent to !!:s/string1/string2/ (see Modifiers below). !# The entire command line typed so far.

There are many options available if you want to create a script using bash history. You can check other history options in the info page. Just type info history to open it. You can clear Linux bash history if it is too large or you don't want other people see what you were doing in the command line terminal. If you want to clear the bash history, use history command with -c option. See example below:
luzar@ubuntu:~$ history -c

Linux history command can be really helpful when we are working in command line terminal. We can save a lot of times not typing regularly used command such as ls, cd and many more. However, keeping all bash history commands also might cause security threat to the system. For example, consider the root bash history file was read by unauthorised person. What you can do is always clear history after root session. You can also delete line in history file. Let's look at the example Linux history file below:
1 2 3 4 5 6 7 8 9 10 updatedb sudo updatedb updatedb sudo updatedb locate mysql cd /var/www/ ls cat index.html ls -l cd ..

If I want to delete the history line number 4, what I have to do is to use history command with '-d 4' option. The -d option deletes history entry while the 4 argument is history entry line 4. See the example below:
kkcjlab@ubuntu-server:~$ history -d 4

Now let's look at the Linux history file again:


1 2 3 4 5 6 7 8 updatedb sudo updatedb updatedb locate mysql cd /var/www/ ls cat index.html ls -l

9 10

cd .. ls -l

The history entry number 4 has been deleted and the previous number 5 entry is now at number 4. Here are other history command options that you can try: -a Appends to history file. -n Loads from history file. -p Performs history lookup/substitution. -r Reads history from a file. -s Adds new history entries.

That is all the Linux history command options regularly used in Linux administration. Secret number two is called Linux automatic command completion. It is another favourite tool used by almost all Linux users. It is a program that help identify what you are going to type in Linux command line and complete the command, words or sentence for you. Learn more about this cool Linux feature in Linux automatic command completion tutorial.

Linux automatic command completion


Linux automatic command completion is a tool or program that can identify what you are typing in the Linux command line terminal and can complete that command, words or sentence for you. This is a really cool feature in Linux. What you need to do to run Linux automatic command completion is pressing the Tab key. It is a program not a magic that can read your mind though. So you need to follow a procedure to use the Linux automatic command completion. Here is the procedure: 1. You must be in the Linux command line terminal or command line interface in x-window. 2. You just key in the first letter of the command you are going to use and then press tab. Linux will automatically complete that command for you. 3. Linux automatic command completion is not going to work if there are other commands, words or sentences that start with the first letter you typed. In this case, you can press Tab key once again (press Tab key two times) to reveal what commands, words or sentences available with that letter. You need to press the second letter or maybe third letter depending on the situation. 4. Linux automatic command completion is not going to work in certain condition such as when you are using man or find commands. 5. Linux automatic command completion is not going to work in text editor. That's some of the conditions regarding Linux automatic command completion. Let's see some examples to make it clear: The first example is we are going to use Linux automatic command completion to complete ls command. So we just type l and press Tab key:
luzar@hitam:~$ l Display all 122 possibilities? (y or n)

What happened above was, when I press l, Linux automatic command completion didn't work. That means there are many commands start with a letter l. So I press Tab key again to reveal what other commands are. And as you can see there are 122 possibilities available. So I just press n to not to display all 122 possibilities. Why? Because I just want to type ls command and I know what it is. The

point here is, if it is a simple command like ls, cd or another 2 or 3 letters commands, we don't need Linux automatic command completion. Now let's see a real useful example. Type cd /v and press Tab. Linux automatic command completion will complete the word to /var/.
luzar@hitam:~$ cd /var/

Next, key in l after the /var/ like in the example below and press Tab. Nothing happened. Press Tab again and Linux will show other possibilities started with the letter l.
luzar@hitam:~$ cd /var/l lib/ lock/ log/

Now, if we want to change directory to lib, then we just need to key in i and press Tab for Linux automatic command completion kick in. However, if we want to change directory to log directory, we need to key in full letters.
luzar@hitam:~$ cd /var/log/ luzar@hitam:/var/log$

That's how Linux automatic command completion works. You don't need to practice using this, instead just use it all the times. This feature use by almost all Linux users. Why? Because it is so helpful. Remember, don't type unless it's necessary, use Tab for Linux automatic command completion. It's fast and it would make you looks like a Linux guru itself. Secret number three is the Linux shortcut keys. Linux has several useful shortcut keys by default that you can use in command line terminal. Learn these shortcut keys or key sequences available in Linux shortcut keys tutorial. That's the basic magic you should learn as a Linux beginner. It's probably enough to impress other gui fellows of yours. Let's continue to other Linux basic commands. The very important Linux command and perhaps the mostly used command in Linux system is the ls command. It is used to view directory contents. Learn how to use ls command to view hidden files, print result in different format, print directory only and many more in Linux directory listing using ls command tutorial.

Linux ls command - Listing directory content


Linux ls command is used to list directory content in Linux command line terminal. In other words, the Linux ls command can be used to view the content of a directory in Linux system. If you are familiar with windows command prompt, or dos, then the equivalent command to the Linux ls is the dir command. Here is a part of the Linux ls command manual page:
NAME ls - list directory contents SYNOPSIS ls [OPTION]... [FILE]... DESCRIPTION List information about the FILEs (the current directory by default). Sort entries alphabetically if none of -cftuvSUX nor --sort.

Linux ls command examples


Linux ls command can be used without any option to view a directory content. When ls command invoked without option, it prints all files and directories except hidden files. Here is an example of ls command used to view / (root) directory:
luzar@hitam:~$ bin/ etc/ boot/ fat-d/ dev/ fat-e/ luzar@hitam:~$ ls / fat-f/ fat-g/ fat-h/ home/ lib/ lost+found/ media/ mnt/ opt/ proc/ root/ sbin/ srv/ sys/ tmp/ usr/ var/

To view all files and directories including hidden files, we can use ls command with -a option. See the example below:
luzar@hitam:~$ ls -a ./ ../ .DCOPserver_hitam_:0@ .DCOPserver_hitam__0 .ICEauthority .VirtualBox/ .Xauthority .gimp-2.4/ .googleearth/ .gqview/ .gstreamer-0.10/ .java/ .kde/ .kderc .qt/ .recently-used.xbel .screenrc .serverauth.3581 .ssh/ .themes/ .thumbnails/ drupal/ dwhelper/ etc/ movies/ musics/ permission.txt screenshots/

The files and directories start with . such as .Xauthority, .kderc and .thumbnails is hidden. The only way to view hidden files is to use -a option, alone or combine with other ls command options. If we want to see details information about directory contents, we can use -l option. See the example of ls -l option below:
luzar@hitam:~$ ls -l /etc total 2056 -rw-r--r-- 1 root root -rw-r--r-- 1 root root drwxr-xr-x 18 root root -rw-r--r-- 1 root root -rw-r--r-- 1 root root drwxr-xr-x 3 root root -rw-r--r-- 1 root root -rw-r--r-- 1 root root drwxr-xr-x 4 root root 3458 18 4096 2561 15067 4096 47 265 4096 2008-09-21 2009-01-07 2009-01-27 2002-02-25 2002-02-25 2008-12-31 2009-02-24 2008-02-17 2008-12-31 11:18 15:13 15:15 04:37 04:37 22:25 02:22 03:35 22:27 DIR_COLORS HOSTNAME X11/ a2ps-site.cfg a2ps.cfg acpi/ adjtime anthy-conf asciidoc/

Linux ls -l command list details of contents such as file or directory permission, ownership, size, creation date and time. For more information about permission, you can check Linux file and directory permissions. The Linux file and directory ownership discuss about Linux ownership. These tutorials also explains more about Linux files and directory. If you want to view directories only, you can used -d option. The example below shows how to use ls -d option to list only directories: Using Linux ls command to view directories only in current directory:
luzar@hitam:~$ ls -d */ Desktop// dwhelper// movies// anime// drupal// etc// luzar@hitam:~$ screenshots// sony// musics// software// tutorials//

We can also view directories only in other directory. The example below shows how to view directories only in /var/log directory using Linux ls command:

luzar@hitam:~$ ls -d /var/log/cups// /var/log/httpd// /var/log/iptraf// /var/log/nfsd// /var/log/packages// luzar@hitam:~$

/var/log/*/ /var/log/removed_packages// /var/log/removed_scripts// /var/log/sa// /var/log/samba// /var/log/scripts//

/var/log/setup// /var/log/uucp// /var/log/vmware//

Another useful option that we can use with Linux ls command is the ls -R option. The ls -R option listing directory content recursively. See the example below:
luzar@hitam:~$ ls -R /var/log/vmware/ /var/log/vmware/: hostd-0.log hostd-3.log hostd-6.log hostd-1.log hostd-4.log hostd-7.log hostd-2.log hostd-5.log hostd-8.log /var/log/vmware/webAccess: client.log proxy.log objectMonitor.log timer.log hostd-9.log hostd-index hostd-trace.log hostd.log@ webAccess/

unitTest.log updateThread.log

viewhelper.log work/

/var/log/vmware/webAccess/work: Catalina/ /var/log/vmware/webAccess/work/Catalina: localhost/ /var/log/vmware/webAccess/work/Catalina/localhost: ui/ /var/log/vmware/webAccess/work/Catalina/localhost/ui: luzar@hitam:~$

The example above shows ls -R listing the /var/log/vmware/ directory content and all sub-directories in it. There are many more options that we can use with the Linux ls command. All the ls examples above are regular options used everyday by Linux users. Check the Linux ls manual page and try what other options can do. When learning all basic Linux commands above, we have come across the Linux cd command. A very simple command yet plays very big role in Linux command line terminal. Check out Linux cd command - explore Linux directory file system to learn what an important command it is.

Linux cd command - explore Linux directory file system


Linux cd command is a command used to change directory in Linux command line terminal. The command just did that. There is no option available for the cd command. Changing directory in Linux is common. So you are going to use Linux cd command a lot when you are working in the Linux command line terminal. Maybe you think that Linux cd command is easy to use. Of course it has no option, so you don't have to worry about that. But using cd command in Linux command line is not as easy as you think. Why? Because when we are using cd command, we are dealing with the Linux file system directory. The Linux cd command itself is simple but the Linux file system directory is not. So the main purpose of this tutorial is to use the Linux cd command to introduce the basic Linux file system directory to a Linux beginner.

Linux cd command introduction


Here is the manual page for cd command:
NAME cd - Change working directory SYNOPSIS cd ?dirName? _________________________________________________________________ DESCRIPTION Change the current working directory to dirName, or to the home directory (as specified in the HOME environment variable) if dirName is not given. Returns an empty string. Note that the current working directory is a per-process resource; the cd command changes the working directory for all interpreters and (in a threaded environment) all threads.

From the manual page, we can understand that what Linux cd command does is to change working directory. The description tells us that, to change directory, use cd dirName where the dirName is the target directory. If cd command was issued without argument, then it'll takes you to your home directory. Let's see an example of this.

Linux cd command examples


First, let's confirm our our home directory. We can check our home directory with Linux env command.
luzar@slackware:~$ env | grep HOME JAVA_HOME=/usr/lib/java HOME=/home/luzar luzar@slackware:~$

That is our home directory. Now we can change to other directory with cd command syntax mentioned above. Let's say our target directory is / directory. So the Linux cd command would be:
luzar@slackware:~$ cd / luzar@slackware:/$

We are now at the / directory. In Linux (and Unix) we call / a root directory. We are now at the highest directory level in the Linux file system. Please don't confused / directory and /root directory. Both are called root directory but the former is the highest directory in Linux and the latter is a home directory for the Linux lord, the root user. If we list / directory content, we can see that /root directory is in the / directory.
luzar@slackware:/$ ls bin/ dev/ home/ lost+found/ boot/ etc/ lib/ media/ luzar@slackware:/$ mnt/ opt/ proc/ root/ sbin/ srv/ sys/ tmp/ usr/ var/

We can say that /root directory is a child directory and the / directory is a parent directory. Now let's get back to our main purpose, which is to demonstrate description from the cd manual page. If we check our working directory now, we would be in / directory. We can prove that with Linux pwd command. The cd manual description states that if dirName is not given, the cd command would take us back to our home directory, which is /home/luzar. Let's see:
luzar@slackware:/$ pwd /

luzar@slackware:/$ cd luzar@slackware:~$ pwd /home/luzar luzar@slackware:~$

The example above proved it. Let us see some more examples about Linux cd command. This time, please remember all the characters and their meaning below: Character Meaning . Current directory ~ Home directory .. Upper directory or parent directory Use ls -a to list all contents including hidden files in our current directory.
luzar@slackware:~$ ls -a ./ .kde/ ../ .kderc .qt/ .screenrc

The file which name starts with . such as .screenrc is a hidden file. Just ignore them for now because they belong to other topic. The important here are those in blue color. Refer to the table above, can you guess what they are? Yes. the single dot (.) is current directory and double dot (..) is upper directory. What happen if we cd into them?
luzar@slackware:~$ cd . luzar@slackware:~$ pwd /home/luzar luzar@slackware:~$ cd .. luzar@slackware:/home$ pwd /home luzar@slackware:/home$

When we issue cd . command, we still in the same working directory. Yes, because single dot (.) means current directory. But when we issue cd .., we were taken to the home directory. Why? Because double dot (..) means upper directory, and /home directory is our parent directory when we issue the command. That's it. We have covered most of the important part of the Linux file system directory using Linux cd command. There are many other things in Linux file system directory that we can explore with the Linux cd command. We'll look at them later in other topics. Here are more useful basic Linux command list that can help you working in the Linux command line terminal: 1) Linux clear command tutorial - Learn Linux clear command which is used to clear terminal screen and see example of the command usage.

Linux clear command


It's quite uncomfortable when working in the Linux command line terminal which is full of text and you have to type command at the command prompt at the bottom of the screen. There is a command in Linux that can wipe the screen clean. The Linux clear command can be used to remove all commands or texts in the command line terminal. Let's check the Linux clear command manual page and see what else it can do. Type man clear at the

Linux terminal command prompt:


luzar@slackware:~$ man clear

This is the result:


NAME clear - clear the terminal screen SYNOPSIS clear DESCRIPTION clear clears your screen if this is possible. It looks in the environ ment for the terminal type and then in the terminfo database to figure out how to clear the screen. clear ignores any command-line parameters that may be present. SEE ALSO tput(1), terminfo(5) This describes ncurses version 5.6 (patch 20071124).

Believe it or not, that's the only text we have for Linux clear command manual page. That means the clear command just meant to do that, clear the screen. Here's an example on how Linux clear command works: Type clear at the command prompt to clear the screen.
Using /etc/random-seed to initialize /dev/urandom. INIT: Entering runlevel: 3 Going multiuser... Starting sysklogd daemons: /usr/sbin/syslogd /usr/sbin/klogd -c 3 -x Activating hardware detection: /etc/rc.d/rc.hotplug start Starting Internet super-server daemon: /usr/sbin/inetd Starting OpenSSH SSH daemon: /usr/sbin/sshd Updating shared library links: /sbin/ldconfig Updating X font indexes: /usr/X11R6/bin/fc-cache Starting sendmail MTA daemon: /usr/sbin/sendmail -L sm-mta -bd -q25m Starting sendmail MSP queue runner: /usr/sbin/sendmail -L sm-msp-queue -Ac -q2m Starting gpm: /usr/sbin/gpm -m /dev/mouse -t imps2 gpm: oops() invoked from gpm.c(977) /dev/mouse: No such device Welcome to Linux 2.6.27.7-smp (tty1) slackware login: bill Password: Linux 2.6.27.7-smp Last login: Sun Jun 21 11:42:55 +0800 2009 on tty4. No mail. bill@slackware:~$ clear

When we enter the clear command, all texts on the current screen will be gone. You can see the command prompt now is at the top of the screen again. That's it. It's a very simple command yet very useful.

2) Linux date command tutorial - Learn more about this important Linux command. The date command can be used to view as well as edit date and time in Linux command line terminal is explained with examples in real situation.

Linux date command


Linux date command is used to set and display date and time in the command line terminal. It is quite an interesting command which allows user to customize the result format when viewing the system date. If we view date command manual page, it says that Linux date command prints or set the system date and time. That means other than displaying date and calendar, date command also capable of managing date and time for Linux system. Here is Linux date command information as you can find it in the manual page:
NAME date - print or set the system date and time SYNOPSIS date [OPTION]... [+FORMAT] date [-u|--utc|--universal] [MMDDhhmm[[CC]YY][.ss]] DESCRIPTION Display the current time in the given FORMAT, or set the system date.

From the synopsis above, we can see that Linux date command supports different format to display date and also provides the option to use utc (Universal Time Coordinated) or universal time (GMTGreenwich Mean Time). Here are explanation and the complete list of options used in the synopsis example above:
OPTION - option to customize date command. FORMAT - controls the output. -u - print or set Coordinated Universal Time. MM - month. DD - day within month. hh - hour. mm - minute. CC - first two digits of year. YY - last two digits of year. ss - second

Note: If an argument starts with +, date prints the `date' prints the current date and time (or the date and time specified by the `--date' in the format defined by that argument. CC, YY and ss are optional.

Linux date command view date and time examples


When issuing date command without any option in Slackware Linux, it displays locale's date and time plus timezone information:
luzar@slackware:~$ date Thu Jul 2 11:21:27 MYT 2009

If we want to check current date and time, invoke date from command line terminal will give us the information we need. If you feel uncomfortable or annoying with the date output format, you can use date command with -R option to display date and time in RFC 2822 format. See date command example below:

luzar@slackware:~$ date -R Thu, 02 Jul 2009 14:15:21 +0800

To view Coordinated Universal Time (UTC), use date command with -u option. You'll see a result like the example below:
luzar@slackware:~$ date -u Thu Jul 2 06:22:50 UTC 2009

To view date and time output in RFC 3339 format use --rfc-3339 option. Specify '--rfc-3339=date' to display date-only output or '--rfc-3339=ns' to show precise time to nanoseconds. Here are examples on how to issue date command with those options:
luzar@slackware:~$ date --rfc-3339=date 2009-07-02 luzar@slackware:~$ date --rfc-3339=seconds 2009-07-02 14:18:23+08:00 luzar@slackware:~$ date --rfc-3339=ns 2009-07-02 14:18:34.629526452+08:00

If you want to check what is the day and date 15 days ago when you take emergency leave, for example, you can issue date command with --date=stringoption. See example below:
root@slackware:~# date --date='15 days ago' Wed Jun 17 04:09:12 MYT 2009

You can also use weeks, months and years with --date=string option:
root@slackware:~# date --date='15 years ago' +'I know what you did on %D' I know what you did on 07/02/94 root@slackware:~# date --date='15 months ago' +'I also know what you did on %F' I also know what you did on 2008-04-02 root@slackware:~# date --date='15 weeks ago' +'You did it again on %A %B %Y'

You did it again on Thursday March 2009

The Linux date example above shows three different formats of output. We can do that using `date' conversion specifiers. Please check date manual pages for more information.

Linux date command set date and time examples


We did mention earlier that Linux date command can be used to set date and time in Linux system. Here are some examples on how to change date and time also the format of the output. Use date command to set date and time in 24 hours format (0-24 format):
root@slackware:~# date '-s 2009-07-02 15:43:13 +0800' Thu Jul 2 15:43:13 MYT 2009

We can also change the way time displayed to 12 hours (1-12 format). See the date command example below:
root@slackware:~# date '-s 2009-07-02 03:48:13 +0800' Thu Jul 2 03:48:13 MYT 2009

That's it.

3) Linux who command - Prints information about current login session. The who command offers some options that user can use to see more details about users such as login time, terminal used and process id. Check this out! Linux who command shows who is logged on to the system. This is a useful command for a Linux system administrator because they can check how many users currently logged in the system and who they are. The Linux who command offers some options that user can use to see more details about users such as login time, terminal used and process id. However that is not the only things the who command can do. We can also use Linux who command to check when was the Linux system last booted and the current system's run level.

Linux who command examples


We already know what Linux who command can do, now it's time to see some examples. Below are the Linux who command examples run with options regularly used by system administrator. Probably the well known Linux who command's option is the am i. When invoke who am i from a Linux command line terminal (and unix as well), the who command prints only the information about user who runs the command.
luzar@ubuntu:~$ who am i luzar pts/0 2009-07-06 22:39 (:0.0)

When we run who with no option in Linux command line terminal, we'll get the result similar to the example below:
luzar@ubuntu:~$ who root tty1 luzar tty7 luzar pts/0 2009-07-06 22:06 2009-07-06 19:17 (:0) 2009-07-06 21:28 (:0.0)

The example above shows two users logged in the Linux system. We can see current users in the system's username are root who logged in tty1 and luzar who's using terminal 7 (tty7), which we know it's the x-window system. The other terminal is pts/0 also by a user named luzar, which means he opened a terminal from x-window. We also see the complete date and time they logged into the Linux system in tty1, tty7 and even when they opened a command line terminal from x-window. So, when we invoke Linux who command without any option, it prints login name, terminal line, login time, and remote hostname or X display information. Linux who -l command example:
luzar@ubuntu:~$ who -l LOGIN tty3 2009-07-06 LOGIN tty5 2009-07-06 LOGIN tty4 2009-07-06 LOGIN tty6 2009-07-06 LOGIN tty2 2009-07-06 19:17 19:17 19:17 19:17 19:17 4439 4432 4431 4441 4438 id=3 id=5 id=4 id=6 id=2

Linux who command print system login processes. Don't get confuse with this option. When running who -l, 'who' list only the entries that correspond to processes via which the system is waiting for a user to login. The user name is always LOGIN. Linux who -m command example:
luzar@ubuntu:~$ who -m luzar pts/0 2009-07-06 21:28 (:0.0)

The Linux who -m command prints only hostname and user associated with stdin. It the same as running who am i command. Linux who -q command example:
luzar@ubuntu:~$ who -q root luzar luzar # users=3

The Linux who -q command prints all login names and the number of users logged on. Using -q option will overrides all other options. Linux who -r command example:
luzar@ubuntu:~$ who -r run-level 2 2009-07-06 19:17 last=

The Linux who -r command prints system's current runlevel. Linux who -T command example:
luzar@ubuntu:~$ who -T root - tty1 2009-07-06 22:06 luzar + tty7 2009-07-06 19:17 (:0) luzar + pts/0 2009-07-06 21:28 (:0.0)

After each login name, Linux who -T command prints a character indicating the user's message status, which: + means allowing `write' messages. - means disallowing `write' messages. ? means cannot find terminal device. Linux who -u command example:
luzar@ubuntu:~$ who -u root tty1 2009-07-06 22:06 00:07 luzar tty7 2009-07-06 19:17 old luzar pts/0 2009-07-06 21:28 . 5465 5506 (:0) 6509 (:0.0)

The Linux who -u command lists users logged in. After the login time, the who command prints the number of hours and minutes that the user has been idle. . means the user was active in the last minute. old means the user has been idle for more than 24 hours. Linux who -b command example:
luzar@ubuntu:~$ who -b system boot 2009-07-06 19:17

The Linux who -b command prints the date and time of last system boot. Linux who -a command example:
luzar@ubuntu:~$ who -a system boot run-level 2 LOGIN tty3 LOGIN tty5 2009-07-06 2009-07-06 2009-07-06 2009-07-06 19:17 19:17 19:17 19:17 last= 4439 id=3 4432 id=5

LOGIN LOGIN LOGIN root luzar luzar

tty4 tty6 tty2 - tty1 + tty7 + pts/0

2009-07-06 19:17 2009-07-06 19:17 2009-07-06 19:17 2009-07-06 22:06 00:32 2009-07-06 19:17 old 2009-07-06 22:39 .

4431 id=4 4441 id=6 4438 id=2 5465 5506 (:0) 6938 (:0.0)

The Linux who -a command is the same as invoke who -b -d --login -p -r -t -T -u. That's all. 4) Linux redirection tutorial - Redirection in Linux means sending command output to another location or file. It is a great support for Linux command. When issuing a command in Linux, we get the result output on the screen monitor. We can send the command result to a file, for example using Linux redirection. Redirection in Linux means sending command output to another location or file. It is a great support for Linux command. Linux redirection is represented by > operator.

Linux redirection
Linux redirection is quite an important command when working in Linux command line terminal. Here is an example of what redirect command can do:
kucing@ubuntu:~$ mkdir examples kucing@ubuntu:~$ man man > examples/linux-manual.txt kucing@ubuntu:~$ ls examples/ linux-manual.txt kucing@ubuntu:~$

The example above shows redirect prints the output of man command to a file. We can use redirect to manipulates the STDOUT and prints the result to other destination. We can also use redirection to create a new file in Linux. For this purpose, we use Linux cat command. See example below:
kucing@ubuntu:~$ cat > examples/new-file.txt This is a an example on how to use Linux redirection to create a new file in Linux. We use Linux cat command and redirection.
kucing@ubuntu:~$ ls examples/ linux-manual.txt new-file.txt kucing@ubuntu:~$ cat examples/new-file.txt This is a an example on how to use Linux redirection to create a new file in Linux. We use Linux cat command and redirection. kucing@ubuntu:~$

We can also use Linux redirection to add or append content to a file. Use double redirection operator (>>) for this job. See example below:
kucing@ubuntu:~$ cat >> examples/new-file.txt This is a new content append to this file. kucing@ubuntu:~$ cat examples/new-file.txt This is a an example on how to use Linux redirection to create a new file in Linux. We use Linux cat command and redirection. This is a new content append to this file. kucing@ubuntu:~$

As you can see, the Linux redirection is quite interesting. It can be really interesting if you are developing a program or configuring a Linux server. You can use Linux redirection to keep all results and errors in a dedicated directory. You can also use redirection to ignore error or warning by sending the output to /dev/null.
kucing@ubuntu:~$ /etc/init.d/apache2 start 2> examples/errors.txt kucing@ubuntu:~$ /etc/init.d/apache2 start 2> /dev/null

That's all for now. 5) Linux pipe tutorial - Linux pipe operator, which is the | symbol offers great benefits when working in Linux command line terminal. It can be used to combine Linux commands and manipulate the command output.

Linux pipe
Linux pipe operator, which is the | symbol offers great benefits when working in Linux command line terminal. It can be used to combine Linux commands and manipulate the command output. Maybe you start thinking that it is a bit advanced for a new user who just learned a few Linux commands and better skip learning it now because it's not very helping for a Linux beginner. Believe me, the sooner you learn it, the more you'll benefits from it. This tutorial will introduce a very basic Linux pipe usage so that a new user can start using it while learning Linux basic commands. Let's see the first example on how to use pipe to combine Linux command and manipulate the command's output.
kucing@ubuntu:~$ ls /etc/ | grep ld.so ld.so.cache ld.so.conf ld.so.conf.d kucing@ubuntu:~$

In the example above, we use ls command to view content of /etc directory. Because the /etc directory has many files and directories, we use Linux pipe (|) to send the output to the next command which is the grep command to grab term that we want (ls.so). Here is another example of how to manipulate command's output using Linux pipe to send it to another command:
kucing@ubuntu:~$ dmesg | less [ 0.000000] Initializing cgroup subsys cpuset [ 0.000000] Initializing cgroup subsys cpu [ 0.000000] Linux version 2.6.27-14-generic (buildd@rothera) (gcc version 4.3.2 (Ubuntu 4.3.2-1ubuntu11) ) #1 SMP Tue Jun 30 19:57:39 UTC 2009 (Ubuntu 2.6.27-14.35-generic) [ 0.000000] BIOS-provided physical RAM map: [ 0.000000] BIOS-e820: 0000000000000000 - 000000000009f800 (usable) [ 0.000000] BIOS-e820: 000000000009f800 - 00000000000a0000 (reserved) [ 0.000000] BIOS-e820: 00000000000dc000 - 0000000000100000 (reserved) [ 0.000000] BIOS-e820: 0000000000100000 - 000000001f680000 (usable) [ 0.000000] BIOS-e820: 000000001f680000 - 000000001f700000 (ACPI NVS) [ 0.000000] BIOS-e820: 000000001f700000 - 0000000020000000 (reserved) [ 0.000000] BIOS-e820: 00000000e0000000 - 00000000f0000000 (reserved) [ 0.000000] BIOS-e820: 00000000fec00000 - 00000000fec10000 (reserved)

[ [ [ [ [ [ [ [ [

0.000000] 0.000000] 0.000000] 0.000000] 0.000000] 0.000000] 0.000000] 0.000000] 0.000000]

BIOS-e820: 00000000fed00000 - 00000000fed00400 (reserved) BIOS-e820: 00000000fed14000 - 00000000fed1a000 (reserved) BIOS-e820: 00000000fed1c000 - 00000000fed90000 (reserved) BIOS-e820: 00000000fee00000 - 00000000fee01000 (reserved) BIOS-e820: 00000000ff000000 - 0000000100000000 (reserved) DMI present. last_pfn = 0x1f680 max_arch_pfn = 0x100000 kernel direct mapping tables up to 1f680000 @ 7000-d000 RAMDISK: 1ee9c000 - 1f66fa50

We use dmesg command in the example above to view Linux bootup messages. To let us read the message line by line, we use Linux pipe to pass the dmesg output to the less command. Those are two examples of Linux pipe which has been used regularly by Linux users especially system administrators when working in Linux command line terminal. It'll be a great help for Linux new user to learn Linux and explore Linux file system for sure. All Linux basic command tutorials above should expose you to the basic concept of running commands in Linux system. However, those commands only prepare you to explore Linux file system. To do a real administration job using Linux commands, you can continue to the next Linux command's topic and learn how to manage Linux user account.

Linux basic commands to manage Linux user account


Linux and Unix commands can be group into several sections depends on the task. Here's the Linux user account related commands list. It contains every Linux commands needed to manage Linux user account. 1) Linux adduser command - This is the command to create a new user account from Linux or Unix shell(terminal). Description and step by step example of Linux "adduser" command. Every Linux user must learn how to create a new user account in Linux system. There should be at least one normal user account in your system. You can't continue using root to learn Linux. It's dangerous because root is a super power user. Some serious mistakes can damage your Linux system. This tutorial will guide user adding new Linux user account using adduser command. This account will be your main account and next time you login into your Linux system, use this account instead of root.

Create new user account using Linux adduser command in Slackware


The command used to create a new user account in Linux and Unix-based operating system is useradd command. In Slackware however, we normally add user account using adduser command. The adduser command has been simplified and made adding a new account in Linux system easier. Here is a part of adduser description from manual page:
DESCRIPTION adduser and addgroup add users and groups to the system according to command line options and configuration information in /etc/adduser.conf. They are friendlier front ends to the low level tools like useradd, groupadd and usermod programs, by default choosing Debian policy conformant UID and GID values, creating a home directory with skeletal configuration, running a custom script, and other features. adduser and addgroup can be run in one of five modes:

Let's try adding a new user account using adduser command and see how easy it is. Switch to a new command line terminal and login as root. Type adduser and press Enter. See example below:
root@slackware:~# adduser Login name for new user []:

What important here is login name part. It is the name of the new user account. Type a simple one word name with no white space. You can put real name later. Enter other information related to the Linux system for the new user. If you are not sure just press enter to use the default value.
Login name for new user []: jadon User ID ('UID') [ defaults to next available ]: Initial group [ users ]: Additional groups (comma separated) []: Home directory [ /home/jadon ] Shell [ /bin/bash ] Expiry date (YYYY-MM-DD) []:

Press Enter each time you finish entering information. Don't worry about the user information yet. You can always add or edit them later with Linux usermod command. For now, just enter what's important. You'll get a summary of the new user account information that you provided just now.
New account will be created as follows: --------------------------------------Login name.......: jadon UID..............: [ Next available ] Initial group....: users Additional groups: [ None ] Home directory...: /home/jadon Shell............: /bin/bash Expiry date......: [ Never ] This is it... if you want to bail out, hit Control-C. Otherwise, press ENTER to go ahead and make the account.

You can cancel the new user account with Ctrl+c key. When you are ready, press Enter to continue making the account. In the next section, you have to provide information about the new user. The most important here is to set a password for the new account. See example below:
Creating new account... Changing the user information for jadon Enter the new value, or press ENTER for the default Full Name []: jadon java Room Number []: 13 Work Phone []: Home Phone []: Other []: Changing password for jadon Enter the new password (minimum of 5, maximum of 127 characters) Please use a combination of upper and lower case letters and numbers. New password: Re-enter new password: Password changed. Account setup complete.

Your new user account setup is complete now.

Create new user account with adduser command in Ubuntu Linux


You can also using adduser command in Ubuntu to create a new user account. It is even simpler than Slackware. Here is an example of creating a new user account in Ubuntu server using adduser command:
luzar@ubuntu:~$ sudo adduser umar Adding user `umar' ... Adding new group `umar' (1005) ... Adding new user `umar' (1004) with group `umar' ... Creating home directory `/home/umar' ... Copying files from `/etc/skel' ... Enter new UNIX password: Retype new UNIX password: passwd: password updated successfully Changing the user information for umar Enter the new value, or press ENTER for the default Full Name []: umar hakimi Room Number []: 133 Work Phone []: 012345678 Home Phone []: 019123456 Other []: 0312345678 Is the information correct? [y/N] y luzar@ubuntu:~$

The adduser command in Ubuntu is slightly different from Slackware. In Ubuntu, you must provide a login name after the adduser command. After that Ubuntu automatically add default group and create a home directory for the new account. Everything else is the same as Slackware. 2) Linux useradd command - The useradd command is common in Unix and Unix-based operating system. This command is use to create a new user account or update default new user information. Highly useful command for system administrator, so new system administrator, check out this tutorial. Manage Linux user account is a very important task in Linux. It begins with creating a user account and creating password for that particular user account and then, you might have to assign group for that user. Maybe at one time you might have to change a user particular (user information) such as update telephone number or department where the user works. You also don't want to keep an account of user who no longer works in your office or temporary officer in your server.

Create user account using Linux useradd command


The Linux useradd command is the traditional command used to create a new user account or modify user's information in Linux system. The useradd command's manual page state very clear about how to do this and it's not very hard to understand. Please read the manual page at least once so that you can see how useradd can assist you doing your administration job. Below is the synopsis from useradd manual page taken from Slackware Linux:
SYNOPSIS useradd [-c comment] [-d home_dir] [-e expire_date] [-f inactive_time] [-g initial_group] [-G group[,...]] [-m [-k skeleton_dir]] [-o] [-p passwd] [-s shell] [-u uid] login useradd -D [-g default_group] [-b default_home] [-e default_expire_date] [-f default_inactive][-s default_shell]

Here is another useradd manual page synopsis taken from Ubuntu Linux:

SYNOPSIS useradd [options] LOGIN useradd -D useradd -D [options]

What you see in other Linux distributions might be different. Other than manual page, you can see synopsis (command's syntax) of useradd command by typing useradd and enter. You should get basic information about useradd command and the right way to issue the command with available options. This is another way of how Linux helps user in command line terminal. This is an example of how to create a new user using useradd command in Slackware Linux:
root@hitam:~# useradd -g users -d /home/karim -s /bin/bash -c temporary -e 2006-06-30 -m karim root@hitam:~#

Here are the meaning of command options used in the example above: -g (user initial group) - users -d (user's home directory when login) - /home/karim -s (user's shell) - /bin/bash -c (comment) - Temporary -e (account expired date) - 2009-11-30 -m (create user's home directory) karim (username of the new account)

All user's information can be found in /etc/passwd file. We can view the file with vi /etc/passwd command.
karim:x:1003:100:temporary:/home/karim:/bin/bash

The useradd -D command can be used to modify user account.

Create password for Linux new user account


Now we have to provide a password for the account we've just created. The command to do the job is Linux passwd command. The format for the passwd command is passwd <username>. If you forgot to put the username, linux changes the current user password (user account we are using now), which is the root password. Let's create password for our new user:
root@slackware:~# passwd karim Changing password for karim Enter the new password (minimum of 5, maximum of 127 characters) Please use a combination of upper and lower case letters and numbers. New password: Re-enter new password: Password changed.

That's it. Now you can switch to other terminal and login with the new user account. 3) Linux userdel command - Learn how to use the Linux userdel command to remove user account from the system. This command will also delete related files in the account. A simple example on how to use userdel command is in here. So check this out. The Linux userdel command is a very simple command. It just did what the name says, delete user.

View the manual page and you can see that, in Slackware synopsis, userdel command has only one option:
SYNOPSIS userdel [-r] login DESCRIPTION The userdel command modifies the system account files, deleting all entries that refer to login. The named user must exist. The options which apply to the userdel command are: -r Files in the user's home directory will be removed along with the home directory itself and the user's mail spool. Files located in other file systems will have to be searched for and deleted manually.

The -r option when used with userdel command will removed user's home directory and the mail spool. If there are other files in other directory, you have to remove them manually. Let's practice using this command now. We are going to delete the user account we created just now, karim user account. As you can see from the manual above, the format for userdel is userdel -r login. 4) Linux finger command - An example on how to use a Linux finger command. The finger command is use to view account user information. The description with example in this tutorial should make user understand better about Linux finger.

Linux finger
The Linux finger command displays information about the system users. We can view all information about user if we know the user account login name. Below are some examples of the Linux finger command with useful options that you can use to view user information. Type 'finger' at the command prompt without any option will give an output of users currently log in the system:
bill@hitam:~$ finger Login Name bill billy jadon root bill@hitam:~$ Tty tty1 tty2 Idle Login Time Apr 10 13:38 Apr 10 14:38 Office Office Phone

The output is the same if we issue Linux finger command with -s option, but this time we are looking at a specific user:
bill@hitam:~$ finger -s bill Login Name Tty bill billy jadon tty1 bill@hitam:~$ Idle Login Time Apr 10 13:38 Office Office Phone

This is what each column means: The column Login is user's login name. The column Name is user's full name. The column Tty is terminal user's login in. The column Idle shows idle time. The column Login Time shows date and time when user login in.

The column Office shows user's office location. The column Office Phone shows user's office phone number. Now, try Linux finger command with -l option:
bill@hitam:~$ finger -l bill Login: bill Name: billy jadon Directory: /home/bill Shell: /bin/bash On since Mon Apr 10 13:38 (MYT) on tty1 No mail. No Plan. bill@hitam:~$

When Linux finger command is issued with -l option, it produces a multi-line format displaying the same result as -s with extra user's home directory, home phone number, shell, mail status, and the contents of the files ``.plan'', ``.project'', ``.pgpkey'' and ``.forward'' from the user's home directory. Remember that the Linux finger command also can be a threat to the Linux system if not properly secured. Attacker can just guess a username and with information gains from finger command, it just a matter of time before your system being compromised. If you can live without the finger command, just disable the daemon. 5) Linux last command - This command is used to show last users logged on in the system. Learn how to use this command in an easy to understand step by step examples.

last command
The Linux last command usage is not only to view user's last login but it can be used to view user's activity in the system. Since all user's activity in the system is logged, last command will search that particular log file, it's /var/log/wtmp. Normal user with no special root privilege can also use last command. This is very interesting because normal user can monitor other user and system activities including root. Let us see some examples. Issuing the Linux last command without any option displays:
bill@slackware:~$ last bill tty1 Mon Apr 10 16:53 still logged in bill tty1 Mon Apr 10 16:47 - 16:53 (00:05) bill tty1 Mon Apr 10 16:20 - 16:47 (00:26) root tty2 Mon Apr 10 14:38 still logged in bill tty1 Mon Apr 10 13:38 - 16:20 (02:42) reboot system boot 2.6.24.5-smp Mon Apr 10 13:34 (03:34) root tty1 Fri Apr 7 18:25 - down (00:15) reboot system boot 2.6.24.5-smp Fri Apr 7 18:24 (00:16) bill tty4 Thu Apr 6 14:21 - down (04:09) reboot system boot 2.6.24.5-smp Thu Apr 6 14:20 (04:09) bill tty4 Thu Mar 23 12:25 - 12:25 (00:00) wtmp begins Wed Jan 4 15:27:32 2008

Isn't it interesting? We can see who's in the system now, in what terminal, times, date, system boot and reboot including kernel version. The last command comes with several options to make system administrator task easier. Below are examples of what options regularly used with last command:

bill@slackware:~$ last tty1 bill tty1 bill tty1 bill tty1 bill tty1 root tty1 wtmp begins Wed Jan 4 15:27:32 2008

Mon Mon Mon Mon Fri

Apr Apr Apr Apr Apr

10 10 10 10 7

16:53 16:47 16:20 13:38 18:25

still logged in 16:53 (00:05) 16:47 (00:26) 16:20 (02:42) down (00:15)

Here we check what root has been doing recently:


bill@slackware:~$ last root root tty1 root tty2 root tty1 root pts/0 :0 root tty wtmp begins Wed Jan 4 15:27:32 2008 Mon Apr Sun Apr Mon Apr Mon Apr Fri Apr 10 16:53 still logged in 9 14:47 - 16:53 (02:06) 10 16:20 - 16:47 (00:26) 10 13:38 - 16:20 (02:42) 7 18:25 - down (00:15)

Names of ttys can be abbreviated, thus last 2 is the same as last tty2.
bill@slackware:~$ last 2 root tty2 root tty2 jadon tty2 jadon tty2 jadon tty2 bill tty2 bill tty2 bill tty2 bill tty2 wtmp begins Wed Jan 4 15:27:32 2008 Mon Apr 10 Sun Apr 9 Thu Mar 8 Thu Mar 8 Mon Jan 23 Mon Jan 16 Thu Jan 5 Thu Jan 5 Thu Jan 5 14:38 14:47 11:06 11:05 10:42 12:57 14:01 10:27 10:22 still logged in 16:53 (02:06) 13:19 (02:12) 11:06 (00:01) 11:04 (00:22) 13:34 (00:36) 17:17 (03:15) down (01:38) 10:22 (00:00)

The Programmer's manual can be viewed by issuing a 'man last' command in the terminal. Here's the complete manual page for the Linux last command:
NAME last, lastb - show listing of last logged in users SYNOPSIS last [-R] [-num] [ -n num ] [-adiox] [ -f file ] [ -t YYYYMMDDHHMMSS ] [name...] [tty...] lastb [-R] [-num] [ -n num ] [ -f file ] [ -t YYYYMMDDHHMMSS ] [-adiox] [name...] [tty...] DESCRIPTION Last searches back through the file /var/log/wtmp (or the file designated by the -f flag) and displays a list of all users logged in (and out) since that file was created. Names of users and tty's can be given, in which case last will show only those entries matching the arguments. Names of ttys can be abbreviated, thus last 0 is the same as last tty0. When last catches a SIGINT signal (generated by the interrupt key, usually control-C) or a SIGQUIT signal (generated by the quit key, usually control-\), last will show how far it has searched through the file; in the case of the SIGINT signal last will then terminate. The pseudo user reboot logs in each time the system is rebooted. Thus last reboot will show a log of all reboots since the log file was created. Lastb is the same as last, except that by default it shows a log of the file /var/log/btmp, which contains all the bad login attempts.

OPTIONS -num This is a count telling last how many lines to show. -n num The same. -t YYYYMMDDHHMMSS Display the state of logins as of the specified time. This is useful, e.g., to determine easily who was logged in at a particular time -- specify that time with -t and look for "still logged in". -R Suppresses the display of the hostname field. -a Display the hostname in the last column. Useful in combination with the next flag. -d For non-local logins, Linux stores not only the host name of the remote host but its IP number as well. This option translates the IP number back into a hostname. -i This option is like -d in that it displays the IP number of the remote host, but it displays the IP number in numbers-and-dots notation. -o Read an old-type wtmp file (written by linux-libc5 applications). -x Display the system shutdown entries and run level changes. SEE ALSO shutdown(8), login(1), init(8)

6) Linux groupadd command - Another important task regarding Linux user account is to manage user group. Creating user group is one of the task Linux or Unix system administrator do regularly. Practice how to create a new group in Linux Bourne again shell (bash) with this tutorial. One of system administrator's job is to manage groups in Linux system. Manage groups task including create new group, assign users to group, remove users from group, delete group and manage group's permission. In this tutorial, we are going to look at some commands needed to manage groups in Linux system.

Linux groupadd command


The groupadd command is used to create a new group in the linux system. Here is a basic information in the groupadd manual page.
NAME groupadd - create a new group SYNOPSIS groupadd [-g GID [-o]] [-f] [-K KEY=VALUE] group DESCRIPTION The groupadd command creates a new group account using the values specified on the command line plus the default values from the system. The new group will be entered into the system files as needed.

From the synopsis above, the basic groupadd format can be as simple as groupadd <new group>. To create a new group, you must be root. Here is an example of how to create a new group using groupadd command:

In slackware, switch to root user to run the command:


root@slackware:~$ groupadd technical

In Ubuntu, you must add sudo to run the command as root:


luzar@ubuntu:~$ sudo groupadd technical

The groupadd command creates a new group account using the values specified on the command line and the default values from the system. The new group will be entered into the system files as needed. All groups can be found in /etc/group file. To view /etc/group, type less /etc/group. The command is the same for Slackware and Ubuntu:
bill@slackware:~$ less /etc/group

Linux groups command


Here is a part of groups command information in the manual page:
NAME groups - print the groups a user is in SYNOPSIS groups [OPTION]... [USERNAME]... DESCRIPTION --help display this help and exit --version output version information and exit Same as id -Gn. If no USERNAME, use current process.

Type 'groups' without any option will display the current user's group name. Here are examples of Linux groups command: Example 1 - Linux groups command with no options.
bill@slackware:~$ groups users floppy audio video cdrom

Example 2 - Linux groups command to check groups of specific user.


luzar@ubuntu:~$ groups aura aura luzar@ubuntu:~$ groups luzar luzar adm dialout cdrom floppy audio dip video plugdev fuse lpadmin admin luzar@ubuntu:~$

If we mention a username after the groups command, it will display user's initial group.

Add user to a new group


We can use Linux usermod command to add user to a new group. Here is an example of how to do it in Ubuntu:
luzar@ubuntu:~$ sudo groups aura [sudo] password for luzar:

aura luzar@ubuntu:~$ sudo usermod -G techdept aura luzar@ubuntu:~$ sudo groups aura aura techdept luzar@ubuntu:~$

Here are the explanation of the above commands. First we used groups username command to view current user's group. Then we use usermod (options) new_group username to add a user to a new group. Finally, we can check user's group again with the groups command. The steps are the same for Slackware, except you must be root and you don't need sudo command. For more information on usermod command, check the Linux usermod command tutorial.

Linux newgrp command


The newgrp command is used to change the current group ID during a login session. Here is an information about newgrp command from the manual page:
NAME newgrp - log in to a new group SYNOPSIS newgrp [-] [group] DESCRIPTION The newgrp command is used to change the current group ID during a login session. If the optional - flag is given, the users environment will be reinitialized as though the user had logged in, otherwise the current environment, including current working directory, remains unchanged.

The current user's primary group is aura. Now we are going to change the primary group to the new group called techdept with newgrp command:
aura@ubuntu:~$ groups aura techdept aura@ubuntu:~$ newgrp techdept aura@ubuntu:~$ groups techdept aura aura@ubuntu:~$

The newgrp changes the current group to the named group, or to the default group listed in /etc/passwd if no group name is given. The user will be prompted for a password if she does not have a password and the group does, or if the user is not listed as a member and the group has a password. The user will be denied access if the group password is empty and the user is not listed as a member.

Linux groupdel command


The last command you need to know to manage groups is the groupdel. Let's see some basic information about groupdel command in the manual:
NAME groupdel - delete a group SYNOPSIS groupdel group DESCRIPTION The groupdel command modifies the system account files, deleting all

entries that refer to group. The named group must exist. You must manually check all file systems to insure that no files remain with the named group as the file group ID. CAVEATS You may not remove the primary group of any existing user. You must remove the user before you remove the group.

Example of groupdel command.


Check whether the group is a primary group for any user:
luzar@ubuntu:~$ less /etc/group luzar:x:1000: admin:x:120:luzar aura:x:1001: jimi:x:1002: alex:x:1003: itdept:x:1004: techdept:x:1005:aura

The user aura is in the techdept group. You can check whether it's a primary group for aura using groups command:
luzar@ubuntu:~$ groups aura aura techdept

When it's confirm that the group you are going to delete is not a primary group for any user, you can safely remove it with groupdel command. See example below:
luzar@ubuntu:~$ sudo groupdel techdept [sudo] password for luzar: luzar@ubuntu:~$ cat /etc/group luzar:x:1000: admin:x:120:luzar aura:x:1001: jimi:x:1002: alex:x:1003: itdept:x:1004:

The techdept group has been removed. 7) Linux usermod command - Here's the most useful command in user account related commands group. The Linux usermod command is use to modify a user account in the system. No doubt this is the command which does many things. Check out this tutorials and learn what regular options used with usermod command.

usermod command
As a Linux user, you must be able to manage user account in the Linux system. You need to know how to edit or modify a Linux user account information, such as change user password, assign groups to user account, remove group from the user account, change user login name, change password and many more. There is one command in Linux that can do all those stuff. That command is usermod command. If you view manual page for Linux usermod command, you can see that the function of usermod command almost the same as useradd command function. Below is a synopsis and description of Linux usermod command taken from the manual page:

SYNOPSIS usermod [-c comment] [-d home_dir [-m]] [-e expire_date] [-f inactive_time] [-g initial_group] [-G group [,...]] [-l login_name] [-p passwd] [-s shell] [-u uid [-o]] [-L|-U] login

DESCRIPTION The usermod command modifies the system account files to reflect the changes that are specified on the command line. As you can see from the synopsis, usermod command options offer the same task that you can do with useradd except usermod can't create a new user. Now let's see some examples on how to use usermod command to edit user account in Linux system. First, create a new user account that we can use to practice using Linux usermod command. In the example below, we use a user account called aura. View current id for aura with Linux id command. See example below:
root@slackware:~# id aura uid=1001(aura) gid=100(users) groups=100(users) root@slackware:~#

If we want to add a new group called vmware to aura, we can use usermod command with -G option. Be careful though, if you use usermod command with -G option alone, all other groups the user currently belongs to will be removed. So it's better to add -a with -G option if you want to add group or append new group. See how to do it with usermod command example below: Linux adding groups using usermod -G command example:
root@slackware:~# usermod -G users,vmware aura root@slackware:~# id aura uid=1001(aura) gid=100(users) groups=100(users),102(vmware) root@slackware:~#

Linux append group using usermod -aG command example:


kkcj@ubuntu:/var/www/kkcj/sites/all/themes$ id kkcj uid=1000(kkcj) gid=1000(kkcj) groups=1000(kkcj),4(adm),20(dialout),24(cdrom),46(plugdev),112(lpadmin),120(admin),122(samb ashare) kkcj@ubuntu:/var/www/kkcj/sites/all/themes$ sudo usermod -aG www-data kkcj sudo: unable to resolve host ubuntu [sudo] password for kkcj: kkcj@ubuntu:/var/www/kkcj/sites/all/themes$ id kkcj uid=1000(kkcj) gid=1000(kkcj) groups=1000(kkcj),4(adm),20(dialout),24(cdrom),33(wwwdata),46(plugdev),112(lpadmin),120(admin),122(sambashare) kkcj@ubuntu:/var/www/kkcj/sites/all/themes$

If we want to set expired date for aura user account, we can use usermod command with -e option. Provide the final date aura user account will be alive in YYYY-MM-DD format. A complete usermod command example with the correct option and syntax is shown below:
root@slackware:~# usermod -e 2010-10-10 aura

We can also set a brief comment about user account using usermod command with -c option. This comment can be seen when we view /etc/passwd file. The example below shows the syntax:
root@slackware:~# usermod -c programmer aura root@slackware:~# less /etc/passwd | grep aura

aura:x:1001:100:programmer:/home/aura:/bin/bash root@slackware:~#

To change a user password with usermod command, we can use usermod -p command. We have to mention username who's password to be changed as in the usermod command example below:
root@slackware:~# usermod -p New_Password aura

If user aura is not login into the system, we can even change the login name.
root@slackware:~# usermod -l auta aura

We use usermod -l option in the example above to change login name for aura. So the username aura has been replaced with the new name auta. If we try to login with username aura now, the system will give login incorrect error because aura is not exist in the system. You can also put all usermod options that you want to use together in one line. Here is the example on how to do that:
root@slackware:~# usermod -g users -d /home/aura -s /bin/csh -c programmer -p aurapasswd01 aura root@hitam:~#

That covers almost everything you need to know about Linux usermod command and how to modify Linux user account.

Linux basic commands to manage file and directory


Another important topic to learn for a beginner to master Linux is how to handle file and directory in the Linux system. Just like using windows operating system, you need to create new files, create new directory, remove files, remove directories, change file name, copy directory and so on. Manage files and directories in Linux system is an administration job and also a part of system security. Every file and directory in Linux belongs to a certain owner and group owner. They also have permissions applied. You need to understand both, Linux ownership and Linux permissions before you can manage files and directories in Linux system. Here is the Linux command list on how to manage Linux file and directory system. They cover most of the Linux basics to handle files and directory including file permissions and ownerships, which is the most important topic here. 1) Linux mkdir command - A basic Linux tutorial with examples on how to use Linux mkdir command to create new directories in Linux system. A simple explanation for a Linux beginner. Directory is a folder to keep sub-directories or related files together. This is important because keeping all files in the proper directory will make Linux system tidy and easier to manage. As you can see in the default Linux system, all directories can be found in / and each directory has related files, for examples the /bin directory contains all system user's binary files. This tutorial will guide Linux new user how to create directory using mkdir command.

Linux mkdir command


Linux mkdir command is similar to Windows/dos mkdir command. It creates directories with the specified names supplied after it. The mkdir command format is mkdir <directory1 directory2 directory3 ...>.

The mkdir command is one of the mostly use command by Linux users, though it just creates new directory. If we look at the mkdir manual page example below, there is not many options available with mkdir command.
NAME mkdir - make directories SYNOPSIS mkdir [OPTION] DIRECTORY... DESCRIPTION Create the DIRECTORY(ies), if they do not already exist. Mandatory arguments to long options are mandatory for short options too. -m, --mode=MODE set file mode (as in chmod), not a=rwx - umask -p, --parents no error if existing, make parent directories as needed -v, --verbose print a message for each created directory --help display this help and exit --version output version information and exit

This is an example of Linux mkdir command used with no option supplied:


bill@slackware:~$ mkdir programs bill@slackware:~$ ls programs/ bill@slackware:~$

As you can see from the example above, when we view the result with ls command, a new directory named programs has been created. The Linux mkdir command also allows you to create multiple directory. Here is an example on how to create multiple directories at once:
bill@slackware:~$ mkdir linux tutorial guide example bill@slackware:~$ ls example/ guide/ linux/ programs/ tutorial/ bill@slackware:~$

Let's try using the options available with mkdir command. The first mkdir option example is the '-mode=MODE':
kkcjlab@ubuntu-server:~$ mkdir --mode=550 linux-tutorial kkcjlab@ubuntu-server:~$ ls -l total 566176 drwxr-xr-x 2 kkcjlab kkcjlab 20480 2009-10-27 15:58 final kem spl 1 dr-xr-x--- 2 kkcjlab kkcjlab 4096 2009-11-02 10:24 linux-tutorial

The mkdir '--mode=MODE' option can be used to sets the permission mode as in chmod. You can read more about chmod in Linux file and directory permissions tutorial.

Here is another mkdir usage example. We are going to use '-p, --parents' which makes all necessary directories even if they dont currently exist.
root@ubuntu-server:/home/kkcjlab# mkdir --parents linux-tutorial/basic-command/mkdir root@ubuntu-server:/home/kkcjlab# ls -R linux-tutorial/ linux-tutorial/: basic-command linux-tutorial/basic-command: mkdir linux-tutorial/basic-command/mkdir: root@ubuntu-server:/home/kkcjlab#

Here is an explanation of the mkdir command above. We use mkdir command to create a new directory in the /linux-tutorial/basic-command directory. The 'linux-tutorial' directory is already exist but we don't have the 'basic-command' directory. This is an example situation when we can use the mkdir '-parents' option to create parent directory we specified even if they dont currently exist. That's it. Creating new directory in Linux is a very easy task even a new user can do the job without any problem. With the basic mkdir examples given above, you can create as many directory as you want. Practice until you understand how to use the mkdir options. Don't worry, you can remove them later because in the next tutorial, you'll learn how to Remove or delete directory with Linux rmdir command. 2) Linux rmdir command - A basic Linux guide with examples on how to use Linux rmdir command to delete directory in Linux command line terminal. Check this out!. As a Linux user, you need to delete or remove unwanted directories in your system to make it clean and tidy. This tutorial will guide a new Linux user to delete directory in Linux using rmdir command.

Linux rmdir command


When there is tool to create something, there must be tool to remove it. The Linux rmdir command is the opposite tool of mkdir command. If mkdir command creates directory then the rmdir command removes directory, but only empty directory. Let's see what is written in rmdir manual page:
NAME rmdir - remove empty directories SYNOPSIS rmdir [OPTION]... DIRECTORY... DESCRIPTION Remove the DIRECTORY(ies), if they are empty. --ignore-fail-on-non-empty ignore each failure that is solely because a directory is non-empty -p, --parents Remove DIRECTORY and its ancestors. to `rmdir a/b/c a/b a'. E.g., `rmdir -p a/b/c' is similar

-v, --verbose output a diagnostic for every directory processed

--help display this help and exit --version output version information and exit

As you can see, there is also not many options available with rmdir. The syntax is similar to the mkdir, just replace it with rmdir, rmdir <new directory>. Despite of the similarity, rmdir is not that popular because it can only delete an empty directory. That means, if a directory contains file or child directory, then rmdir is useless. You can't delete a directory without delete its content first. Try this example:
luzar@slackware:~$ luzar@slackware:~$ luzar@slackware:~$ luzar@slackware:~$ child/ file.txt luzar@slackware:~$ mkdir parent mkdir parent/child touch parent/file.txt ls parent/

We created a directory with a child and a file in it. Now let us try to delete the parent directory:
luzar@slackware:~$ rmdir parent/ rmdir: parent/: Directory not empty luzar@slackware:~$

We can't delete the parent directory because it's not empty. Is that bad? No it's not. The rmdir reminds us that the directory is not empty. There maybe contains useful data. So, check that first, and if it's rubbish, then delete all the data and after that you can delete the directory itself. Here is another good thing about Linux rmdir command:
luzar@slackware:~$ ls -l parent/ total 4 drwxr-xr-x 2 luzar users 4096 2008-12-18 03:15 child/ -rw-r--r-- 1 luzar users 0 2008-12-18 03:16 file.txt luzar@slackware:~$ rm parent/file.txt luzar@slackware:~$ rmdir -p parent/child/ luzar@slackware:~$ ls Desktop/ testsamba/ luzar@slackware:~$

When using rmdir with -p option, rmdir will remove the parent as well (of course in condition the parent and child contain no file). So that concludes the rmdir command tutorial. If you want to more information about deleting Linux directory, for example, how to delete or remove directory with subdirectory and files in it, take a look at Linux rm command - delete file and directory in Linux tutorial. 3) Linux mv command - move or rename files and directory in Linux - Move or change location of a file in Linux using mv command. You can also use Linux mv command to rename a file or a directory. The Linux mv command is used to move file or directory in Linux system. When we move a file or directory to a new location, we changed its location. That means we didn't duplicate the file or directory and didn't leave a copy in the original location. So, understand the statement, we can also use mv command to rename file in the same directory. The Linux mv command also allows us to move multiple files to a new location in the Linux system.

Linux mv command syntax


In order to use Linux mv command, we need to know the command's syntax. Below is a part of Linux mv manual page:
NAME mv - move (rename) files SYNOPSIS mv [OPTION]... [-T] SOURCE DEST mv [OPTION]... SOURCE... DIRECTORY mv [OPTION]... -t DIRECTORY SOURCE... DESCRIPTION Rename SOURCE to DEST, or move SOURCE(s) to DIRECTORY.

You can see the mv command syntax in the manual page's 'SYNOPSIS' section above. Basically, to move files we'd use:
mv [OPTION] [-T] SOURCE DEST

Where: SOURCE - The file that we want to move. DEST - The new destination for the file. To move multiple files, use the mv command's syntax below:
mv [OPTION] SOURCE1 SOURCE2 SOURCE3... DIRECTORY

To move a directory, use the mv command's syntax below:


mv [OPTION] [-t] SOURCE DEST

Here are options available with Linux mv command:


-b like --backup but does not accept an argument -f, --force do not prompt before overwriting -i, --interactive prompt before overwrite --strip-trailing-slashes remove any trailing slashes from each SOURCE argument -S, --suffix=SUFFIX override the usual backup suffix -t, --target-directory=DIRECTORY move all SOURCE arguments into DIRECTORY -T, --no-target-directory treat DEST as a normal file -u, --update move only when the SOURCE file is newer than the destination file or when the destination file is missing -v, --verbose explain what is being done

How to move files using Linux mv command


Let's take a look at this example to see how mv command works: 1. First, create a new directory named owner and make a new file named history.txt file in user's home directory. 2. Redirect the history output to a file name history.txt with '>'. The command is history > history.txt. 3. Use 'ls' command to see the result. 4. Move the history.txt file to another directory using mv command. To use mv command to move a file to another location, you can use mv <source> <destination> format.

See the step by step example below:


luzar@slackware:~$ mkdir owner luzar@slackware:~$ ls owner/ luzar@slackware:~$ luzar@slackware:~$ history.txt owner/ luzar@slackware:~$ luzar@slackware:~$ .: owner/ ./owner: history.txt luzar@slackware:~$ history > history.txt ls mv history.txt owner/ ls -R

We can view the result with 'ls -R' to view a directory content recursively. See that history.txt has been moved into /owner directory? That's how to use mv command to move file in Linux system. Can we move more than one file in Linux using the mv command? Yes we can. Here is an example on how to move multiple files using Linux mv command:
luzar@slackware:~/examples$ ls BUKUMERAH-BM.pdf UserManual.pdf hardwarePrices.pdf luzar@slackware:~/examples$ mv UserManual.pdf hardwarePrices.pdf /home/luzar/slackware/ luzar@slackware:~/examples$ ls /home/luzar/slackware/ UserManual.pdf hardwarePrices.pdf luzar@slackware:~/examples$ ls BUKUMERAH-BM.pdf luzar@slackware:~/examples$

Here is the explanation of the example above. The UserManual.pdf and hardwarePrices.pdf are source files. The /home/luzar/slackware/ is the destination directory. See that when we move files using Linux mv command, it doesn't leave source copy in the original location. The mv command move the source, not duplicate it. How to move directory in Linux? Basically, it's the same as moving file. Here is an example on how to move a directory called 'labu' to another location (another directory called 'labi') using Linux mv command:
luzar@slackware:~$ mv labu labi luzar@slackware:~$ ls labi/ labu/ luzar@slackware:~$

The example above shows the labu directory has been moved to a destination directory called labi. Can we move not empty directory? Yes, we can move a directory with all its content including child directory and files.

Linux rename file or rename directory using mv command


The next thing you can do with Linux mv command is, you can rename file or rename directory. There is no ren command in Linux. The usual commands used to rename file

in Linux is mv, rename or cp command. Now let's see the mv command first, rename and cp command later. Remember that when we move a file using mv command, we didn't leave a copy in the original location? What happens if we move a file to its original location? Here is what happens:
luzar@slackware:~$ mv examples.tar . mv: `examples.tar' and `./examples.tar' are the same file luzar@slackware:~$

Linux warns us that we are moving the same file in the same directory. If we change the file's name, it should be ok, isn't it? Let's see another example:
luzar@slackware:~$ mv examples.tar move.tar luzar@slackware:~$ ls | grep tar examples.tar.gz move.tar

There we go. So, if we change the file's name, we can move the file in its original location or more accurately, we rename file. Hence, to rename file in Linux, we can use mv command and change the destination file name. Here is another example on how Linux rename file works:
luzar@slackware:~/slackware$ mv move.tar rename/NewName.tar luzar@slackware:~/slackware$ ls rename examples.tar.gz NewName.tar luzar@slackware:~/slackware$

The example above shows how to rename file and move it to a new directory. The mv command also can be used to rename directory. The format is still the same 'mv <source> <destination>' Below is an example on how to rename directory in Linux using mv command:
luzar@slackware:~$ luzar@slackware:~$ buzz/ rename/ luzar@slackware:~$ luzar@slackware:~$ labu/ rename/ luzar@slackware:~$ mkdir buzz ls mv buzz labu ls

You can see from example above, the 'buzz' directory has been renamed to 'labu' directory. Can we rename directory not empty? Yes we can. That's all about how to use Linux mv command to move or rename files in Linux system. You can check other tutorials regarding file and directory management in the manage file and directory index page. 4) Linux cp command - how to copy file and directory in Linux - The cp command is used to copy file or directory to another location or directory in Linux system. A great yet simple tool to backup files. Check out regular options used with cp command in this step by step tutorial.

Linux 'cp' command


Linux 'cp' command is used to copy files and directories in Linux command line terminal. To copy file means to duplicate a file or make an extra copy of a file. The cp command is quite important and used frequently when we work in the command line terminal. Normally, we use the cp command to backup a file by making extra copy of the original file. A situation example is when we are going to edit an important file such as a server configuration file. We can either copy one file to a given destination, or copy many files to a destination directory. The cp command also can be used to copy directory in Linux. Let's see how to use the Linux cp command.

Linux cp command syntax


A command syntax is a synopsis, the format on how to issue the command to do specific task. We can check Linux cp command syntax using the 'man cp' command. Here is a part of the cp command's manual page:
NAME cp - copy files and directories SYNOPSIS cp [OPTION]... [-T] SOURCE DEST cp [OPTION]... SOURCE... DIRECTORY cp [OPTION]... -t DIRECTORY SOURCE... DESCRIPTION Copy SOURCE to DEST, or multiple SOURCE(s) to DIRECTORY.

If you are really a Linux beginner and cannot understand the synopsis in manual page above, below are the Linux cp command syntax which we can use to copy file or directory in Linux system: Linux cp command syntax to copy a single file or directory: cp [option] SOURCE DESTINATION Here are the syntax explanations: [option] - options available that we can used to customize cp command. SOURCE - the original file (or directory). Provide a full directory path if you are running cp command from other directory. DESTINATION - the new target or directory to put the duplicate file (or directory). Linux cp command syntax to copy multiple files: cp [option] [SOURCE1 SOURCE2 SOURCE3 ...] DESTINATION The [SOURCE1 SOURCE2 SOURCE3 ...] is multiple files that are going to be copied. If sources are from different directories, you have to provide a complete path for each source. Here are important Linux cp command's options that regularly used to copy files in Linux system:
-f, --force if an existing destination file cannot be opened, remove it and try again -i, --interactive prompt before overwrite -R, -r, --recursive copy directories recursively -s, --symbolic-link make symbolic links instead of copying -u, --update copy only when the SOURCE file is newer than the destination file or when the destination file is missing -v, --verbose explain what is being done --help display this help and exit

Let's see how to use the cp options above with some examples.

Linux cp command examples


Here are examples and explanations on how to copy files and directories in Linux system.

Linux copy file examples


The Linux cp command's option is not mandatory if we want to copy files only. The cp command can be used without any option. See the Linux copy file example below:
luzar@slackware:~/etc$ cp BUKUMERAH-BM.pdf ../examples/

In the example above, BUKUMERAH-BM.pdf is the source file that we want to copy. The '../example' is the destination directory. If you wonder why there is a '..' before the /example, the explanation is, the '..' is a 'path' for the destination directory. The '..' means the /example directory is one directory above the current directory we are working now. We can also write the full path like '/home/luzar/examples/'. You can check Linux file system structure overview for more information about Linux directory. Our next example is how to use Linux cp command to copy multiple files to a target directory. Here is the example:
luzar@slackware:~/etc$ cp -i UserManual.pdf BUKUMERAH-BM.pdf /home/luzar/examples/ cp: overwrite `/home/luzar/examples/BUKUMERAH-BM.pdf'? n

When we use '-i' option with the cp command, it will prompt us if the file we are copying already exist in the destination directory, so we can confirm whether to overwrite it or not. You can answer with y (yes) or n (No). This is perfect if we are going to copy multiple files in a regular update directory. Also notice that this time we used a full path for the destination directory. We can also force Linux to copy file using the 'cp -f' command. Here is the example:
luzar@slackware:~$ cp -f examples/new-file.txt examples/awareness/

Another example of Linux cp command's option usage is the 'cp -s', which makes a symbolic links instead of copying the real file. The command syntax is different here. When using cp with -s option, we mention the target file first followed by the name of the symbolic link. Here is the example:
luzar@slackware:~$ cd examples/ luzar@slackware:~/examples$ ls awareness errors.txt linux-manual.txt new-file.txt luzar@slackware:~/examples$ rm new-file.txt luzar@slackware:~/examples$ cp -s awareness/new-file.txt new-file.txt luzar@slackware:~/examples$ ls -l total 40 drwxr-xr-x 2 luzar users 4096 2009-11-03 20:55 awareness -rw-r--r-- 1 luzar users 53 2009-07-13 14:11 errors.txt -rw-r--r-- 1 luzar users 30804 2009-07-13 13:22 linux-manual.txt lrwxrwxrwx 1 luzar users 22 2009-11-03 21:10 new-file.txt -> awareness/new-file.txt

Here is the explanation. First I change directory to the example directory and delete a file named 'newfile.txt, the file that I forcefully copied in the Linux copy file example earlier. Then I use the 'cp -s' command to create a symbolic link in the current directory pointing to the original file in awareness directory.

Linux copy directory examples


We can also use cp command to copy directory. The '-R' or 'r' option is needed to recursively copy the

sub-directory and files in that directory. See the Linux copy directory example below:
luzar@slackware:~$ luzar@slackware:~$ total 3940 -rw-r--r-- 1 luzar -rw-r--r-- 1 luzar drwxr-xr-x 2 luzar luzar@slackware:~$ cp -r slackware examples/ ls -l examples/ users 113556 2009-02-25 23:13 BUKUMERAH-BM.pdf users 3903990 2009-02-25 23:29 UserManual.pdf users 4096 2009-02-25 23:39 slackware/

In the example above, we copy a directory named slackware to another directory named examples. We can verbosely copy directory to see what files and directories have been copied. Invoke cp with -v from the command prompt will print details about what happens. See Linux cp example below:
luzar@slackware:~$ cp -rv awareness/ examples/ `awareness/' -> `examples/awareness' `awareness/iklan.png' -> `examples/awareness/iklan.png' `awareness/syarat-diploma.png' -> `examples/awareness/syarat-diploma.png' `awareness/permohonan01.png' -> `examples/awareness/permohonan01.png' `awareness/bpkkedumy.png' -> `examples/awareness/bpkkedumy.png' `awareness/syarat_permohonan.png' -> `examples/awareness/syarat_permohonan.png' `awareness/cara_memohon.png' -> `examples/awareness/cara_memohon.png' `awareness/info_sijil.png' -> `examples/awareness/info_sijil.png' `awareness/eborang.png' -> `examples/awareness/eborang.png' luzar@slackware:~$

This is an example of the Linux cp command with '-u' option. The cp -u copy only when the SOURCE file is newer than the destination file or when the destination file is missing:
luzar@slackware:~$ touch awareness/newfile.txt luzar@slackware:~$ cp -rvu awareness/ examples/ `awareness/newfile.txt' -> `examples/awareness/newfile.txt' luzar@slackware:~$

Here is the explanation of the example above. To show how 'cp -u' command works, we create a new file in the awareness directory (touch awareness/newfile.txt). When we invoke cp -rvu awareness/ examples/, only the 'newfile.txt' which is the new file were copied. Don't worry about duplicate file or directory. This is really useful when backing up a regularly updated directory. Here is another example on how to use Linux copy command to copy file and directory in Linux command line terminal. Example below shows how to copy file to the current directory: First, here is an example content of a directory named 'awareness':
luzar@slackware:~$ cd awareness/ luzar@slackware:~/awareness$ ls ../Desktop/kursus/ configuration.php images search-engine-optimization-starter-guide.pdf ebooks notes templates extensions releases training-workflow.odt luzar@slackware:~/awareness$

If I want to copy 'configuration.php' file to the current directory, the copy command would be like the example below:
luzar@slackware:~/awareness$ cp ../Desktop/kursus/configuration.php . luzar@slackware:~/awareness$ ls bpkkedumy.png eborang.png newfile.txt syarat_permohonan.png cara_memohon.png iklan.png permohonan01.png configuration.php info_sijil.png syarat-diploma.png

luzar@slackware:~/awareness$

The symbol '.' represents current directory. To copy the whole directory to the current directory, we can use the same method but with -r option added. See the example below:
luzar@slackware:~/awareness$ cp -r ../Desktop/kursus/ . luzar@slackware:~/awareness$ ls bpkkedumy.png eborang.png kursus syarat-diploma.png cara_memohon.png iklan.png newfile.txt syarat_permohonan.png configuration.php info_sijil.png permohonan01.png luzar@slackware:~/awareness$

That's all examples of Linux copy file and Linux copy directory using cp command. The important thing to remember about Linux cp command is, to copy directory, you have to provide the -r or -R option(switch). It's optional to use an option(or arguments) with cp command to copy file depends on your need. The different between Linux cp command and Linux mv command is, the cp command duplicate the source file and move it to a new location while the mv command move the source (original) file. So the Linux cp command is the perfect choice to backup files and directories in Linux system. 5) Linux scp command - copy file and directory from remote computer - What scp does is remotely copying files from other system plus safety transfer. Learn this useful command here. There is a secure copy command in Linux that you can use to copy file or directory from remote computer. This is definitely a good option if you are going to transfer data remotely and need an encryption. The command we are talking about is the Linux scp command. We can run scp command from any Linux distribution's command line terminal. The Linux scp comes together with ssh server package. So, to use scp command, the remote machine or the Linux server must have ssh server installed and running. If you want to install scp server in Ubuntu, you have to install ssh server package. The install ssh in Ubuntu tutorial describes all about ssh installation if you need help. For just scp installation in Ubuntu, you can see an example below. scp server is already in your system if you are using Slackware because scp included in Slackware default installation.

How to install scp in Ubuntu


As we mention earlier, scp included in the ssh package, so we'll use apt-get to install ssh package:
luzar@ubuntu:~$ sudo apt-get install ssh [sudo] password for luzar: Reading package lists... Done Building dependency tree Reading state information... Done The following extra packages will be installed: openssh-server Suggested packages: rssh molly-guard openssh-blacklist openssh-blacklist-extra The following NEW packages will be installed: openssh-server ssh 0 upgraded, 2 newly installed, 0 to remove and 0 not upgraded. Need to get 286kB of archives. After this operation, 827kB of additional disk space will be used.

Do you want to continue [Y/n]? Y Get:1 http://archive.ubuntu.com intrepid/main openssh-server 1:5.1p1-3ubuntu1 [285kB] Get:2 http://archive.ubuntu.com intrepid/main ssh 1:5.1p1-3ubuntu1 [1246B] Fetched 286kB in 9s (29.4kB/s) Preconfiguring packages ... Selecting previously deselected package openssh-server. (Reading database ... 130928 files and directories currently installed.) Unpacking openssh-server (from .../openssh-server_1%3a5.1p1-3ubuntu1_i386.deb) ... Selecting previously deselected package ssh. Unpacking ssh (from .../ssh_1%3a5.1p1-3ubuntu1_all.deb) ... Processing triggers for ufw ... Processing triggers for man-db ... Setting up openssh-server (1:5.1p1-3ubuntu1) ... Creating SSH2 RSA key; this may take some time ... Creating SSH2 DSA key; this may take some time ... * Restarting OpenBSD Secure Shell server sshd [ OK ] Setting up ssh (1:5.1p1-3ubuntu1) ... luzar@ubuntu:~$

If somehow your Slackware server doesn't have ssh server, you can install it online as Ubuntu server above using slackpkg command. That's it. Now you have scp in your Ubuntu system. To start using scp to transfer file or directory, let's see the command's usage.

Linux scp command syntax and examples


The Linux scp command is a very useful tool for a remote copy. It is a better option than rcp because it uses encryption just like ssh program. In fact, it uses ssh for data transfer authentication. That means, you certainly need to provide login name and password of the target/destination computer. To start using Linux scp program, let's look at the most important part, the command syntax or command format. This is the Linux scp command syntax to send file or directory to a remote computer: scp -r [/path/filename] [login name@ip address] : . This is the Linux scp command syntax to retrieve file or directory from a remote computer: scp -r [login name@ip address] : [/path/filename] . Here are the meaning of scp command options: -r = recursively copy entire directory . = current directory '/path/filename' is the complete directory path and name where the file resides. 'login name@ip address ' is the target/destination computer. You have to provide your login name and ip address and will be asked for user password. Dot (.) at the end of the command means the files will be copied to the current directory. Of course you can change the destination to any directory you wish, just type the full path and directory name to replace the dot(.). You can find more details in the scp manual page by invoking man scp from Linux command line terminal, which is recommended, if you could at least read it once to get a better understand of the command.

Now that you already understand how scp command works, let's see some actual examples taken from Ubuntu client. Example on how to send file to a remote computer with scp command in Ubuntu Linux using ip address:
luzar@ubuntu:~$ scp UserManual.pdf luzar@192.168.1.6:. luzar@192.168.1.6's password: UserManual.pdf 100% 3812KB luzar@ubuntu:~$ 3.7MB/s 00:01

The scp command example above shows I am sending a file named UserManual.pdf from my computer to a remote computer with an ip address 192.168.1.6. The file UserManual.pdf must be in our home directory. If not, please provide a complete directory path. The file will be saved in luzar's home directory. I specified the user name which I want to login with (remember that we need to provide a valid username and password) and enter the password afterward. Here is the example on how to retrieve file from a remote computer using scp command in Linux. This time we are using remote server's hostname:
luzar@ubuntu:~$ scp luzar@slackware:/home/luzar/netfilter.pdf . luzar@slackware's password: netfilter.pdf 100% 367KB 367.2KB/s luzar@ubuntu:~$ 00:00

The scp command example above shows that I was retrieving a file named netfilter.pdf from a remote computer with an ip address 192.168.1.6. Notice that this time I used a full directory path to the file which I want to get. We can also use scp command to transfer multiple files at once to a remote computer. See the example below:
luzar@ubuntu:~$ scp Interfaces.txt new_file02.txt labu@10.21.36.3:. Password: Interfaces.txt 100% 268 0.3KB/s new_file02.txt 100% 51 0.1KB/s luzar@ubuntu:~$ 00:00 00:00

We can also use wild card with scp command such as * to copy all files. If you feel that copying the whole directory is a better idea, here is an example of scp command used to transfer a directory to a remote computer:
luzar@ubuntu:~$ scp -r folder labu@10.21.36.3:. Password: luzar@ubuntu:~$

We use scp -r option in the example above to recursively copying a directory named folder. You can also use scp command to transfer file or directory to other Linux computer using Windows operating system. Get Putty to login to the Linux server and use scp to copy file or directory to a remote computer (Linux computer) just as examples above. Finally, if for any reason you need to uninstall scp from you Ubuntu server, you can do so by removing ssh package. You can use apt-get remove ssh command or apt-get purge ssh command. You can also use autoremove option like the example below:
luzar@ubuntu:~$ sudo apt-get autoremove ssh [sudo] password for luzar: Reading package lists... Done Building dependency tree

Reading state information... Done The following packages will be REMOVED: ssh 0 upgraded, 0 newly installed, 1 to remove and 0 not upgraded. After this operation, 45.1kB disk space will be freed. Do you want to continue [Y/n]? Y (Reading database ... 130944 files and directories currently installed.) Removing ssh ... luzar@ubuntu:~$

That cover almost all about how to use Linux scp command to copy files or directory from remote computer. Now you should understand that scp is about transferring files or directory to or from a remote computer. It is similar to the ftp protocol. In fact, scp is a perfect choice to transfer an important file because it supports data encryption. If you prefer ftp protocol, you can check ftp client guide for ftp commands tutorial, install and configure proftpd in Ubuntu tutorial and install and configure vsftpd in Slackware Linux on how to install ftp server in your Linux. 6) Linux rm command - delete file and directory in Linux - The rm command is used to remove files or directory. In Linux system there is no del or delete command. So user who familiar with windows or dos command prompt, please take note. It's rm not del command. Check this tutorial for more information about how to delete file or directory in Linux system. Delete file and directory in Linux is regular whether you do server administration job or using Linux desktop as an end user. Linux is different from windows operating system, where permission and security is very important in Linux and a default part of the system. Root user has full power like administrator in windows operating system, where you can delete anything and everything in the system. Because root user is god in Linux, we were advised to do our normal job as a normal user. Being a normal user, we can only delete user file and directory and that does not affect the Linux system. That also means, we don't have privilege to remove other users' files as well. If your duty needed you to clean system files and directory, as well as user data, (such as maintain Linux ftp server) then switch to root user or gain root privilege only when you have to.

Linux rm command
The Linux rm command is used to delete file or directory in Linux. There is no delete or del command like DOS. Normally, to remove a directory in Linux, we would use the rmdir command. But that will only works if the directory is empty. Here's where the Linux rm command will come into part. It has lots of useful options too. Here's the synopsis and description from the Linux rm command's manual page which explains all about the command:
SYNOPSIS rm [options] file... POSIX options: [-fiRr] [--] GNU options (shortest form): [-dfirvR] [--help] [--version] [--] DESCRIPTION rm removes each given file. By default, it does not remove directories. But when the -r or -R option is given, the entire directory tree below the specified directory is removed (and there are no limitations on the depth of directory trees that can be removed by `rm -r'). It is an error when the last path component of file is either . or .. (so as to avoid unpleasant surprises with `rm -r .*' or so).

We can use Linux rm command to delete a normal file without using any option. While to delete a directory, we can use rm -r option. Let's see some examples.

Examples on how to delete files and directory using Linux rm command


First, make sure you login as a normal user. Create a directory labi in user's home directory for this example.
bill@slackware:~$ mkdir labi bill@slackware:~$ ls labi/ labu/ owner/

Create a file named sejarah.txt in labi directory. Here's a tip to create a simple file in linux, use touch command:
bill@slackware:~$ touch labi/sejarah.txt bill@slackware:~$ ls labi sejarah.txt

Now use 'rm' to delete labi directory:


bill@slackware:~$ rm labi rm: cannot remove `labi': Is a directory bill@slackware:~$ rmdir labi rmdir: `labi': Directory not empty bill@slackware:~$

What's wrong? We can't delete labi directory with rm, ok. It's a directory, so use rmdir instead. But that's also failed, labi directory is not empty. Remember that rmdir only remove an empty directory? To remove a directory, the '-r' option is needed. So use rm -r option to delete a directory and all files in it.
bill@slackware:~$ rm -r labi bill@slackware:~$ ls labu/ owner/

bill@slackware:~$

What if we have a large directory with many child directories and files in it? Linux will prompt for a confirmation to delete every files. So the rm -r option seem inefficient this time. In this situation we use the -f option together with -r. Here's and example:
bill@slackware:~$ rm -rf labu bill@slackware:~$

If we use the rm -rf option to remove a directory, Linux will remove the directory and its child without bothering us. The -f option means, just delete and don't ask for my permission. I know what I'm doing. Well, that's true. Only use the -f option if you know what you are doing. My advice is, never issue the rm -rf / command as a root because that will remove all your Linux system. 7) Linux locate command tutorial - Linux locate command is a search utility in Linux. It can be found by default in almost all Linux distributions including Slackware and Ubuntu Linux. This tutorial is a basic locate command guide for a new Linux user. Check this out! Linux locate command is a search utility in Linux. It can be found by default in almost all Linux

distributions including Slackware and Ubuntu Linux. This tutorial is a basic locate command guide for a new Linux user. If you view locate command in Linux manual page, you will see the slocate command manual instead. The Linux locate command manual page has been replaced with slocate, the secure locate command. Don't worry about that because you can use the locate command with the help of this tutorial. When you first run locate command from Linux command line terminal, you'll get fatal error like the example below:
root@slackware:~# locate php.ini-recommended locate: fatal error: Could not find user database '/var/lib/slocate/slocate.db': file or directory root@slackware:~# No such

Don't worry, that does not means your Linux locate command is not working. The error stated that '/var/lib/slocate/slocate.db' could not be found. That means Linux doesn't have locate database yet. What you can do is to run updatedb command. Login into command line terminal and su - to gain root privilege. See an example below for the complete steps:
luzar@slackware:~$ su Password: root@slackware:~# updatedb

If you are using Ubuntu, use sudo updatedb command and provide your password. The database update process will take some times. When it finished, you can try using Linux locate command again to search for file. To find a file in Linux system using locate command or to locate a file, we just invoke locate filename from the command line terminal. Below is an example on how to search file using Linux locate command:
root@slackware:~# locate php.ini-recommended /etc/httpd/php.ini-recommended root@slackware:~#

Sometimes you'll get warning when running locate command such as the example below:
root@slackware:~# locate php.ini-recommended locate: warning: database /var/lib/slocate/slocate.db' is more than 8 days old /etc/httpd/php.ini-recommended root@slackware:~#

As mentioned in the locate warning, your database has not been update for several days. The effect is the latest data has not been update into the database yet. So the locate command won't find the latest data. You have to run the updatedb command again to update the database. You can write a script to tell Linux cron to run updatedb everyday if you want. If you want to use Linux slocate command instead of the locate command, you can manually install it using package management system. If you are using Ubuntu, you can use apt-get or aptitude from desktop. Below is an example on how to install slocate using apt-get command in Ubuntu command line:
luzar@ubuntu:~$ sudo apt-get install slocate Reading package lists... Done Building dependency tree Reading state information... Done The following packages were automatically installed and are no longer required: swh-plugins libqt4-dbus libboost-thread1.34.1 libboost-date-time1.34.1 python-openssl libqtcore4 libqt4-sql libphonon4 libqt4-xml libqt4-network libqt4-designer libqtgui4 libboost-filesystem1.34.1 libqt4-script

libquicktime1 libmlt-data Use 'apt-get autoremove' to remove them. The following NEW packages will be installed: slocate 0 upgraded, 1 newly installed, 0 to remove and 0 not upgraded. Need to get 32.0kB of archives. After this operation, 156kB of additional disk space will be used. Get:1 http://archive.ubuntu.com intrepid/main slocate 3.1-1.1ubuntu4 [32.0kB] Fetched 32.0kB in 2s (11.5kB/s) Selecting previously deselected package slocate. (Reading database ... 131308 files and directories currently installed.) Unpacking slocate (from .../slocate_3.1-1.1ubuntu4_i386.deb) ... Processing triggers for man-db ... Setting up slocate (3.1-1.1ubuntu4) ... Adding group `slocate' (GID 127) ... Done. WARNING: You should run '/etc/cron.daily/slocate' as root. locate will not work properly until you do or until it is run by cron (it is daily). luzar@ubuntu:~$

We can remove package suggested by Ubuntu using apt-get autoremove command. Here is the example:
luzar@ubuntu:~$ sudo apt-get autoremove swh-plugins libqt4-dbus libboost-thread1.34.1 libboost-date-time1.34.1 [sudo] password for luzar: Reading package lists... Done Building dependency tree Reading state information... Done The following packages were automatically installed and are no longer required: python-openssl libqtcore4 libqt4-sql libqt4-xml libqt4-network libqtgui4 libboost-filesystem1.34.1 libquicktime1 libmlt-data The following packages will be REMOVED: libboost-date-time1.34.1 libboost-filesystem1.34.1 libboost-thread1.34.1 libmlt-data libphonon4 libqt4-dbus libqt4-designer libqt4-network libqt4-script libqt4-sql libqt4-xml libqtcore4 libqtgui4 libquicktime1 python-openssl swh-plugins 0 upgraded, 0 newly installed, 16 to remove and 0 not upgraded. After this operation, 31.0MB disk space will be freed. Do you want to continue [Y/n]? Y (Reading database ... 131319 files and directories currently installed.) Removing libboost-date-time1.34.1 ... Removing libboost-filesystem1.34.1 ... Removing libboost-thread1.34.1 ... Removing libmlt-data ... Removing libphonon4 ... Removing libqt4-designer ... Removing libqt4-script ... Removing libqt4-dbus ... Removing libqt4-network ... Removing libqt4-sql ... Removing libqt4-xml ... Removing libqtgui4 ... Removing libqtcore4 ... Removing libquicktime1 ... Removing python-openssl ... Removing swh-plugins ... Processing triggers for libc6 ... ldconfig deferred processing now taking place Processing triggers for python-support ... Processing triggers for doc-base ...

Processing 1 removed doc-base file(s)... Registering documents with scrollkeeper... luzar@ubuntu:~$

Run /etc/cron.daily/slocate command to activate slocate and then run slocate -u option to create slocate database starting at path /:
luzar@ubuntu:~$ sudo /etc/cron.daily/slocate luzar@ubuntu:~$ sudo slocate -u [sudo] password for luzar:

Below is information about slocate command that you can find in manual page:
NAME slocate - Security Enhanced version of the GNU Locate
SYNOPSIS slocate slocate slocate ] [-f ] [-u]> slocate [-qi] [-d ] [--database=] [-i] [-r ] [--regexp=] [-qv] [-o ] [--output=] ] [-c] ] [-Vh] [--version] [--help]

slocate

[-e

DESCRIPTION Secure Locate provides a secure way to index and quickly search for all files on your system regardless of ownership. It uses incremental encoding just like GNU locate to compress its database to make searching faster, but it will also check file permissions and ownership before displaying matched entries so that users will not see files they do not have access to. Note that permissions and ownership are not stored in the database. This manual page documents slocate. slocate enables system users to search entire filesystems without displaying unauthorized files.

Here is an example using slocate command to find file in Linux system:


luzar@ubuntu:~$ slocate -qi my.cnf /etc/mysql/my.cnf

Here is another example of slocate command:


luzar@ubuntu:~$ sudo slocate -U /etc [sudo] password for luzar: luzar@ubuntu:~$ slocate -qi --database=/etc samba /etc/samba /etc/samba/gdbcommands /etc/samba/dhcp.conf /etc/samba/smb.conf /etc/dhcp3/dhclient-enter-hooks.d/samba /etc/pam.d/samba /etc/apparmor.d/abstractions/samba luzar@ubuntu:~$

First we create slocate database starting at path /etc directory. Then we issue slocate command to find a file or term in the database. This is a great option if you want to find a certain term in a particular directory.

E. Linux Basic Commands To Manage File System


These are another useful Linux basic commands for beginner to learn and explore the Linux system. Linux file system related commands are those commands you need to deal with file system such as mounting and unmounting a file system (such as windows FAT file system), view file system and hard disk space and many more. Here is the list of regular used Linux commands to handle file system in Linux: 1) Linux mount command - Linux mount command is used to mount a file system. Linux does not mount file system automatically when you insert a thumb drive or external hard disk. This is because mounting a file system involves security and permission. Read more information in this tutorial. This is a guide on how to mount and unmount thumb drive or usb drive in Linux operating system. Some Linux distributions such as Ubuntu desktop will automatically mount the usb drive while others like Slackware does not. So here is all information you need about mount and unmount usb drive in Linux.

Linux mount usb drive


To use thumb drive in Linux, the device must first be mounted into the system. In older days, you must specify the file system type so Linux can mount it to he system. Today, Linux is clever enough to recognise it and manually mounting the file system is much easier. Here is what the mount command means: mount - The mount command serves to attach the file system found on some device to the big file tree. Conversely, the umount(8) command will detach it again. This is an example on how to mount a USB drive (thumb drive) in Linux: 1. Plug in the usb drive into the usb port on your computer. Wait a few seconds until your Linux system detect it. If not, pull the usb drive and plug in again. If you are using Ubuntu desktop, the usb drive will be detected and mounted automatically. In Ubuntu server command line terminal, a message will appear to notice you that some information about the usb drive that has been plug in. If nothing happens, you can check the information in the /proc directory. From the command prompt, type 'cat /proc/scsi/scsi' to read the scsi file.
root@slackware:~# cat /proc/scsi/scsi Attached devices: Host: scsi0 Channel: 00 Id: 00 Lun: 00 Vendor: ATA Model: WDC WD800JD-75JN Rev: 05.0 Type: Direct-Access ANSI SCSI revision: 05 Host: scsi2 Channel: 00 Id: 00 Lun: 00 Vendor: Kingston Model: DataTraveler 2.0 Rev: 1.02 Type: Direct-Access ANSI SCSI revision: 02

The highlighted text in red shows that the usb drive (thumb drive) is detected. Note that in real situation, the text is in white colour (default) not red. It's highlighted for the sake of learning. You can see the detail in Host, Vendor and Type. If Linux can't detect the usb drive and the usb drive data cannot be found in /proc/scsi/scsi, run rescan-scsi-bus -l from Slackware command line terminal. Below is the example:
root@slackware:~# rescan-scsi-bus -l Host adapter 2 (ata_piix) found. Host adapter 3 (ata_piix) found. Host adapter 4 (ata_piix) found.

Host adapter 5 (ata_piix) found. Host adapter 6 (pata_marvell) found. Host adapter 7 (pata_marvell) found. cat: /sys/class/scsi_host/host8/proc_name: No such file or directory Host adapter 8 () found. cat: /sys/class/scsi_host/host9/proc_name: No such file or directory Host adapter 9 () found. Scanning SCSI subsystem for new devices Scanning host 2 channels 0 for SCSI target IDs 0 1 2 3 4 5 6 7, LUNs Scanning for device 2 0 0 0 ... OLD: Host: scsi2 Channel: 00 Id: 00 Lun: 00 Vendor: ATA Model: WDC WD1600AAJS-0 Rev: 05.0 Type: Direct-Access ANSI SCSI revision: 05 Scanning host 3 channels 0 for SCSI target IDs 0 1 2 3 4 5 6 7, LUNs Scanning for device 3 0 0 0 ... OLD: Host: scsi3 Channel: 00 Id: 00 Lun: 00 Vendor: HL-DT-ST Model: DVDRAM GSA-H62N Rev: CL00 Type: CD-ROM ANSI SCSI revision: 05 Scanning host 4 channels 0 for SCSI target IDs 0 1 2 3 4 5 6 7, LUNs Scanning for device 4 0 0 0 ... OLD: Host: scsi4 Channel: 00 Id: 00 Lun: 00 Vendor: ATA Model: ST3250820SV Rev: 3.AC Type: Direct-Access ANSI SCSI revision: 05 Scanning host 5 channels 0 for SCSI target IDs 0 1 2 3 4 5 6 7, LUNs Scanning host 6 channels 0 for SCSI target IDs 0 1 2 3 4 5 6 7, LUNs Scanning host 7 channels 0 for SCSI target IDs 0 1 2 3 4 5 6 7, LUNs Scanning host 8 channels 0 for SCSI target IDs 0 1 2 3 4 5 6 7, LUNs Scanning for device 8 0 0 0 ... NEW: Segmentation fault root@slackware:~#

0 1 2 3 4 5 6 7

0 1 2 3 4 5 6 7

0 1 2 3 4 5 6 7

0 0 0 0

1 1 1 1

2 2 2 2

3 3 3 3

4 4 4 4

5 5 5 5

6 6 6 6

7 7 7 7

2. The next step is to check with dmesg command to see what drive your thumb drive is. From the command line, type dmesg | grep sd (dmesg pipe grep sd). See example below:
root@slackware:~# dmesg |grep sd SCSI device sda: 156250000 512-byte hdwr sectors (80000 MB) SCSI device sda: drive cache: write back SCSI device sda: 156250000 512-byte hdwr sectors (80000 MB) SCSI device sda: drive cache: write back sda: sda1 sda2 < sda5 sda6 sda7 > Attached scsi disk sda at scsi0, channel 0, id 0, lun 0 SCSI device sdb: 1007616 512-byte hdwr sectors (516 MB) sdb: Write Protect is off sdb: Mode Sense: 23 00 00 00 sdb: assuming drive cache: write through SCSI device sdb: 1007616 512-byte hdwr sectors (516 MB) sdb: Write Protect is off sdb: Mode Sense: 23 00 00 00 sdb: assuming drive cache: write through sdb: sdb1 Attached scsi removable disk sdb at scsi2, channel 0, id 0, lun 0 root@slackware:~#

If you installed KDE, thumb drive or usb drive will be detected automatically when you plug it in. You can check what drive your thumb drive represents by looking at the device property. Here are steps on how you can check your thumb drive name from x-window kde or gnome: Step 1 - Open System from kde desktop.

Step 2 - Open Storage media.

Step 3 - Right-click thumb drive icon and choose Properties. The thumb drive name displays at the top of the newly open pane (Properties title).

3. Now you can 'su' and create a proper directory to mount your thumb drive in /mnt directory. The standard form of the mount command, is mount -t type device dir. This tells the kernel to attach file system found on device (-t option for file system type) at the directory dir. The file system types which are currently supported include: adfs, affs, autofs, cifs, coda, coherent, cramfs, ebugfs, devpts, efs, ext, ext2, ext3, hfs, hfsplus, hpfs, iso9660, jfs, minix, msdos, ncpfs, nfs, nfs4, ntfs, proc, qnx4, ramfs, reiserfs, romfs, smbfs, sysv, tmpfs, udf, ufs, umsdos, usbfs, vfat, xenix, xfs, xiafs. From the command line, type mount -t vfat /dev/sdb1 /mnt/usb and enter. Change directory into /mnt/usb directory. Note - Replace sdb1 with your thumb drive name and /mnt/usb with your mount directory.
bill@slackware:~$ bill@slackware:~$ su Password:

root@slackware:~# root@slackware:~# mount -t vfat /dev/sdb1 /mnt/usb root@slackware:~# cd /mnt/usb root@slackware:~# ls nbtscan-1.5.1a/ snort-2.0.5.tar.gz nbtscan-1.5.1.tar.gz wintest* root@slackware:~#

If it's not working, or you are not sure of file system type, just ignore the -t option. Try this instead: mount <device> <destination>:
root@slackware:~# mount /dev/sdb1 /mnt/usb root@slackware:~# cd /mnt/usb root@slackware:/mnt/usb# ls ls nbtscan-1.5.1a / snort-2.0.5.tar.gz nbtscan-1.5.1.tar.gz wintest * root@slackware:~#

If you want to access usb drive in Ubuntu using terminal, Ubuntu desktop automatically mount usb drive in /media/disk. So what you have to do is just cd into /media/disk directory.

Linux unmount usb drive


umount - The umount command detaches the file system(s) mentioned from the file hierarchy. A file system is specified by giving the directory where it has been mounted. Giving the special device on which the file system lives may also work, but is obsolete, mainly because it will fail in case this device was mounted on more than one directory. Note that a file system cannot be unmounted when it is `busy' - for example, when there are open files on it, or when some process has its working directory there, or when a swap file on it is in use. The offending process could even be umount itself - it opens libc, and libc in its turn may open for example locale files. A lazy unmount avoids this problem. To unmount file system or devices, you must be out of the directory you want to unmount. Type cd and enter to go to the user's home directory. Then perform this command:
root@slackware:/mnt/usb# cd root@slackware:~# umount /mnt/usb/ root@slackware:~#

Replace the target directory with the location where you mounted your usb device or thumb drive directory. If there is no error, your device should be unmounted now. you can try listing the directory again to be sure:
root@slackware:~# umount /mnt/usb/ root@slackware:~# ls /mnt/usb/

You can check Cannot unmount dvd - Device is busy for more information about umount problem. It is a tutorial about unmonting cdrom/dvd device. You cannot open dvd or cdrom drive without successfully unmount the device. There are several reasons why you cannot unmount dvd drive. One example is when you invoke mv command instead of cp command to transfer data from dvd to the hard disk drive. What happen when you try to move content from a read only device? Of course you'll get the "cannot move" message warns you that the content is read only. If you were moving large data, then you can

stop the process with "Ctrl+c". You can continue to transfer the data but use the cp command this time. The problem occurs when you try to unmount the dvd drive afterward. You'll find that the device is busy and you cannot unmount dvd drive. The situation above is just an example. This tutorial explains how to find solution if you cannot unmount dvd drive because the device is busy. Let's see an example when device is busy and you cannot unmount dvd drive:
root@slackware:~# umount /mnt/dvd/ umount: /mnt/dvd: device is busy. (In some cases useful info about processes that use the device is found by lsof(8) or fuser(1))

When a device is busy, it must be running a process or other process is still using the device. In this case, we must stop the running process before unmount the device. We can use ps command to check the running process. If you are clueless about what process to look for, just issue "ps aux" command. Look at the username or terminal you are using now. See the example below:
luzar root luzar root root 27955 27969 28000 28006 28088 0.0 0.0 0.0 0.1 0.0 0.0 0.0 0.9 0.0 0.0 3576 1940 pts/1 3076 1736 pts/1 39116 20036 ? 2052 780 pts/1 2564 936 pts/1 Ss R S T R+ 23:08 23:08 23:09 23:10 23:28 0:00 0:00 0:00 0:01 0:00 -bash -su kio_file [kdein mv drupal etc m ps aux

The example above shows that I was using the pts/1 terminal. There must be something I did which made the dvd device busy. Now I can grab all processes running from pts/1 terminal and start looking for the answer there.
root@slackware:~# ps luzar 27955 0.0 root 27969 0.0 root 28006 0.1 root 28088 0.0 aux | grep pts/1 0.0 3576 1940 pts/1 0.0 3076 1736 pts/1 0.0 2052 780 pts/1 0.0 2564 936 pts/1 Ss R T R+ 23:08 23:08 23:10 23:28 0:00 0:00 0:01 0:00 -bash -su mv drupal etc m ps aux

We can see that the mv process is still running. That's what makes the device busy. We can terminate the process with kill command. See the example below:
root@slackware:~# kill -9 28006 [1]+ Killed mv * /home/luzar/ (wd now: ~) (wd: /mnt/dvd)

Check if the mv process still there with ps aux command. See an example below:
root@slackware:~# ps aux USER PID %CPU %MEM root 1 0.0 0.0 root 2 0.0 0.0 VSZ 772 0 RSS TTY 324 ? 0 ? STAT START Ss 16:59 S TIME COMMAND 0:01 init [3]

The mv pid is 28006. It's not there, which means we successfully terminate the process. You can also use "grep" command to grab word from the ps result. See the example below:
root@slackware:~# ps aux | grep mv root@slackware:~#

There are many reasons why you cannot unmount dvd drive. But there must be a process that still using the device which made the device busy. You can always

check the process and kill the process id like the example above. If you are unsure of what makes your device busy, check bash history. Maybe you'll get the idea of what went wrong.

2) Linux fdisk command - check hard disk partitions - The Linux fdisk command is a popular tool used to create hard disk partitions. However, fdisk command also can be used to check hard disk partitions on the running Linux system. You need to check your hard disk partitions from time to time to keep your eyes on hard disk usage and to make sure your hard disk is not out of space. Normally, the /home partition always running out of space if you setup Linux as a desktop. It's because you are using a normal user account to do your job and keep all data in /home/ directory. If you setup your Linux as a server, then give most of your hard disk space to the main partition (the mount point). For example, if you setup a web server, then, you should give /var directory a bigger space because all website data will be kept in /var/www/htdocs. That's why it's very important for you to properly plan the hard disk partition and give a proper hard disk space to every mount point (directory) depends on the needs. This tutorial is about how to check hard disk partitions from an already running Linux operating system using Linux fdisk command. If you are looking for fdisk tutorial to partition your hard disk, check the step by step partition guide with screenshots in Slackware hard disk partition with fdisk tutorial.

Check hard disk partitions with Linux fdisk command


The Linux fdisk command is a popular tool used to create hard disk partitions. Whoever installed Slackware Linux before should be familiar with Linux fdisk command. However, fdisk command also can be used to check hard disk partitions on the running Linux system. It's not only Slackware but you can find fdisk command in other Linux distributions too including Ubuntu. So this tutorial can be used to check hard disk space usage in any Linux distributions. You need root privileges to run fdisk, otherwise you will have a command not found message if you are using Slackware or Cannot open /dev/sda if you are using Ubuntu like in the example below: Invoke fdisk command without root privilege in Slackware Linux.
luzar@slackware:~$ fdisk -l -bash: fdisk: command not found

Invoke fdisk command without root privilege in Ubuntu Linux.


luzar@ubuntu:~$ fdisk -l /dev/sda Cannot open /dev/sda

You can use su - in Slackware and for Ubuntu, you can use sudo command to gain root privilege. Slackware example:
luzar@slackware:~$ su Password:

Ubuntu example:
luzar@ubuntu:~$ sudo fdisk -l /dev/sda [sudo] password for luzar: Disk /dev/sda: 80.0 GB, 80026361856 bytes 255 heads, 63 sectors/track, 9729 cylinders Units = cylinders of 16065 * 512 = 8225280 bytes

Disk identifier: 0xa403a403 Device Boot /dev/sda1 /dev/sda2 /dev/sda3 * /dev/sda4 /dev/sda5 Start 1 5100 125 2557 5100 End 124 9728 2556 5099 9728 Blocks 995998+ 37182442+ 19535040 20426647+ 37182411 Id 82 f 83 83 7 System Linux swap / Solaris W95 Ext'd (LBA) Linux Linux HPFS/NTFS

Partition table entries are not in disk order

Here is a part of manual page for Linux fdisk command. The important part is the SYNOPSIS which will be our reference in all the examples.
NAME fdisk - Partition table manipulator for Linux SYNOPSIS fdisk [-u] [-b sectorsize] [-C cyls] [-H heads] [-S sects] device fdisk -l [-u] [device ...] fdisk -s partition ... fdisk -v DESCRIPTION Hard disks can be divided into one or more logical disks called parti tions. This division is described in the partition table found in sector 0 of the disk. In the BSD world one talks about `disk slices' and a `disklabel'.

We can use the second syntax in the synopsis above to check hard disk partitions in our current system. If we want to check the first hard disk in Linux system, issue fdisk command and the first hard disk. See example below:
root@slackware:~# fdisk -l /dev/sda Disk /dev/sda: 160.0 GB, 160041885696 bytes 255 heads, 63 sectors/track, 19457 cylinders Units = cylinders of 16065 * 512 = 8225280 bytes Disk identifier: 0xb262b262 Device Boot /dev/sda1 /dev/sda2 /dev/sda3 /dev/sda4 root@slackware:~# Start 1 251 3899 5116 End 250 3898 5115 19457 Blocks 2008093+ 29302560 9775552+ 115202115 Id 82 83 83 83 System Linux swap Linux Linux Linux

The Linux fdisk -l option if invoked without giving specific hard disk, will print hard disk based on data found in the /proc/partitions.
root@slackware:~# fdisk -l Disk /dev/sda: 160.0 GB, 160041885696 bytes 255 heads, 63 sectors/track, 19457 cylinders Units = cylinders of 16065 * 512 = 8225280 bytes Disk identifier: 0xb262b262 Device Boot /dev/sda1 Start 1 End 250 Blocks 2008093+ Id 82 System Linux swap

/dev/sda2 /dev/sda3 /dev/sda4

251 3899 5116

3898 5115 19457

29302560 9775552+ 115202115

83 83 83

Linux Linux Linux

Disk /dev/sdb: 250.0 GB, 250059350016 bytes 255 heads, 63 sectors/track, 30401 cylinders Units = cylinders of 16065 * 512 = 8225280 bytes Disk identifier: 0xa5bbe44b Device Boot /dev/sdb1 /dev/sdb2 /dev/sdb5 /dev/sdb6 /dev/sdb7 /dev/sdb8 root@slackware:~# Start 1 5100 5100 8924 15298 21672 End 5099 30400 8923 15297 21671 30400 Blocks 40957686 203230282+ 30716248+ 51199123+ 51199123+ 70115661 Id 7 f 7 7 7 7 System HPFS/NTFS W95 Ext'd (LBA) HPFS/NTFS HPFS/NTFS HPFS/NTFS HPFS/NTFS

The result above shows all hard disk used in the current Linux system. If we want to print size in sector instead of cylinder, add -u option with the command. See example below:
root@slackware:~# fdisk -l -u /dev/sda Disk /dev/sda: 160.0 GB, 160041885696 bytes 255 heads, 63 sectors/track, 19457 cylinders, total 312581808 sectors Units = sectors of 1 * 512 = 512 bytes Disk identifier: 0xb262b262 Device Boot Start /dev/sda1 63 /dev/sda2 4016250 /dev/sda3 62621370 /dev/sda4 82172475 root@slackware:~# End 4016249 62621369 82172474 312576704 Blocks 2008093+ 29302560 9775552+ 115202115 Id 82 83 83 83 System Linux swap Linux Linux Linux

We can display the size of partition in block using fdisk - s option. However we need to provide the partition name. See the example below:
root@slackware:~# fdisk -s /dev/sda4 115202115 root@slackware:~#

That's all. Now you can check your hard disk usage with Linux fdisk command and take appropriate action before any partition runs out of space. Remember to check hard disk space regularly or you can write a script to let you know if a certain partition is reaching the limit. 3) Linux df command - monitor Linux hard disk usage - Report file system disk space usage with Linux df command. See an example on how to use df command in Linux system. It is important for system administrator to monitor hard disk usage from time to time. This will allow earlier action to be taken if hard disk is going out of space. In Linux, there are two commands that we can use to monitor and check hard disk usage, df command and fdisk command.

Linux df command
The Linux df command reports the amount of disk space used and available on mounted file systems. That means, df command can't show unmounted usb drive such as thumb drive or external hard disk. With no arguments, df command reports the space used and available on all currently mounted file systems (of all types). Otherwise, df command reports on the file system containing each file name

argument. Here is an example of Linux df command with no option:


luzar@hitam:~$ df Filesystem /dev/root /dev/sda3 /dev/sda4 /dev/sdb1 /dev/sdb5 /dev/sdb6 /dev/sdb7 /dev/sdb8 tmpfs luzar@hitam:~$ 1K-blocks 76904380 19236340 55716572 40957684 30716248 51199120 51199120 70115660 1034776 Used Available Use% Mounted on 5329876 67667900 8% / 725080 17534108 4% /usr/local 8929648 43956676 17% /home 16202484 24755200 40% /fat-d 10799096 19917152 36% /fat-e 41318108 9881012 81% /fat-f 35078560 16120560 69% /fat-g 30306508 39809152 44% /fat-h 0 1034776 0% /dev/shm

Here is an example of Linux df command with -a option:


luzar@hitam:~$ df -a Filesystem 1K-blocks /dev/root 76904380 /proc 0 sysfs 0 usbfs 0 /dev/sda3 19236340 /dev/sda4 55716572 /dev/sdb1 40957684 /dev/sdb5 30716248 /dev/sdb6 51199120 /dev/sdb7 51199120 /dev/sdb8 70115660 tmpfs 1034776 luzar@hitam:~$ Used Available Use% Mounted on 5329876 67667900 8% / 0 0 - /proc 0 0 - /sys 0 0 - /proc/bus/usb 725080 17534108 4% /usr/local 8933312 43953012 17% /home 16202484 24755200 40% /fat-d 10799096 19917152 36% /fat-e 41318108 9881012 81% /fat-f 35078560 16120560 69% /fat-g 30306508 39809152 44% /fat-h 0 1034776 0% /dev/shm

The -a option prints all including dummy file system. Let's try another option, -h.
luzar@hitam:~$ df -h Filesystem Size /dev/root 74G /dev/sda3 19G /dev/sda4 54G /dev/sdb1 40G /dev/sdb5 30G /dev/sdb6 49G /dev/sdb7 49G /dev/sdb8 67G tmpfs 1011M luzar@hitam:~$ Used Avail Use% Mounted on 5.1G 65G 8% / 709M 17G 4% /usr/local 8.6G 42G 17% /home 16G 24G 40% /fat-d 11G 19G 36% /fat-e 40G 9.5G 81% /fat-f 34G 16G 69% /fat-g 29G 38G 44% /fat-h 0 1011M 0% /dev/shm

The df -h command will give output in human readable format. As you can see in the example above, df command prints output in M and G after the size, which represents MB and GB (also K for KB but they are not in my output). Another option that we can use with df command is -l, which prints only local file system. If you want to check file system type, use df command with -T option like the example below:
luzar@hitam:~$ df -T Filesystem Type 1K-blocks /dev/root ext3 76904380 /dev/sda3 ext3 19236340 /dev/sda4 ext3 55716572 /dev/sdb1 fuseblk 40957684 Used Available Use% Mounted on 5329880 67667896 8% / 725080 17534108 4% /usr/local 8951748 43934576 17% /home 16202484 24755200 40% /fat-d

/dev/sdb5 fuseblk /dev/sdb6 fuseblk /dev/sdb7 fuseblk /dev/sdb8 fuseblk tmpfs tmpfs luzar@hitam:~$

30716248 51199120 51199120 70115660 1034776

10799096 41318108 35078560 30306508 0

19917152 9881012 16120560 39809152 1034776

36% 81% 69% 44% 0%

/fat-e /fat-f /fat-g /fat-h /dev/shm

You probably noticed that the ntfs-3g file system has been detected as fuseblk file system. You must have read about fuse file system before. Fuse is a file system in userspace. The fuseblk file system features including device locking and unlocking, allow sharing file system for multiple mounts, and other extra features. You can also make df prints only a certain file system type, such as ext3. The right option to use is -t or --type=ext3. See the example below:
luzar@hitam:~$ df --type=ext3 Filesystem 1K-blocks /dev/root 76904380 /dev/sda3 19236340 /dev/sda4 55716572 luzar@hitam:~$ df -t fuseblk Filesystem 1K-blocks /dev/sdb1 40957684 /dev/sdb5 30716248 /dev/sdb6 51199120 /dev/sdb7 51199120 /dev/sdb8 70115660 luzar@hitam:~$ Used Available Use% Mounted on 5329908 67667868 8% / 725080 17534108 4% /usr/local 9114888 43771436 18% /home Used Available Use% Mounted on 16202484 24755200 40% /fat-d 10799096 19917152 36% /fat-e 41318108 9881012 81% /fat-f 35078560 16120560 69% /fat-g 30306508 39809152 44% /fat-h

You can use df -x option to exclude a file system type. The -x does the opposite of what -t did. See the example below:
luzar@hitam:~$ df -x fuseblk Filesystem 1K-blocks /dev/root 76904380 /dev/sda3 19236340 /dev/sda4 55716572 tmpfs 1034776 luzar@hitam:~$ Used Available Use% Mounted on 5329924 67667852 8% / 725080 17534108 4% /usr/local 9130472 43755852 18% /home 0 1034776 0% /dev/shm

F. Linux basic commands to manage Linux processes


Linux processes (similar to Windows processes) which also called Linux services are programs running when Linux is started. This is an easy jargon and most used recently to help less confusing Linux beginner (which mostly have Windows background). However, the term 'daemon' is widely used in Linux community to refer the Linux services. Here is the Linux command list that every user should know to view and manage Linux processes: 1) Linux ps command - Report a snapshot of current processes. Learn more about Linux ps command such as different options in Unix, BSD and how Linux process is different from Windows process.

What is a Linux process?


A Linux process is a program running in the Linux system. Depending on Linux distributions, it's also known as service. In Linux community however, a Linux process is called daemon.

When you start a program or running an application in Linux, you actually execute that program. A Linux process (a daemon), running in foreground or in the background, uses memory and CPU resources. That's why we need to manage Linux process. Keeping unused Linux process running in the system is a waste and also expose your system to security threat. We are going to learn and practice Linux process management using Linux ps command, pstree command and top command in this tutorial.

Linux process management


In Linux, every running process or daemon is given an identity number called PID (Process ID). The process id is unique. We can terminate unused program in the system by stopping its process id. In order to manage Linux processes, we need to identify some process information such as who's responsible for the process, which terminal the process is running from and what command used to run the process. We can view a particular Linux process by providing its characteristic. A Linux command which can be used to check the ID of a running process in Linux system is the ps command.

Linux ps command
Linux ps command reports a snapshot of the current processes.
root@slackware:~# ps PID TTY TIME CMD 353 tty1 00:00:01 bash 736 tty1 00:00:00 ps root@slackware:~#

COMMAND-LINE OPTIONS This version of ps accepts several kinds of options: 1) UNIX options, which may be grouped and must be preceeded by a dash. 2) BSD options, which may be grouped and must not be used with a dash. 3) GNU long options, which are preceeded by two dashes. Here are more examples from the ps command manual page:
EXAMPLES To see every process on the system using standard syntax: ps -e ps -ef ps -eF ps -ely To see every process on the system using BSD syntax: ps ax ps axu To print a process tree: ps -ejH ps axjf To get info about threads: ps -eLf ps axms To get security info:

ps -eo euser,ruser,suser,fuser,f,comm,label ps axZ ps -eM To see every process except those running as root (real & effective ID) ps -U root -u root -N

Because Linux is a multi-user, multitasking operating system, it can run many processes at a time. With multitasking system, multiple processes are allowed to operate simultaneously without interfering with each other, while a multi-user system allows multiple users to use the system simultaneously. If one process has problem and stops functioning, it will not affect another process because each process runs in its own protected memory space.

Linux pstree command


Other than Linux ps command, a pstree command can also be used to view a currently running process in the Linux system. Instead of viewing details in list, pstree command displays a process in a tree diagram. Lets practice some Linux pstree command examples. Login as a normal user and from the command line, type 'pstree' and press Enter:
root@slackware:~# pstree init-+-5*[agetty] |-atd |-bash---pstree |-bdflush |-crond |-inetd |-keventd |-khubd |-kjournald |-klogd |-ksoftirqd_CPU0 |-kswapd |-kupdated |-mdrecoveryd |-2*[sendmail] |-sshd |-syslogd `-udevd root@slackware:~#

You should get a result similar like this. At the top of the result is a process called init. The init is process control initialization. It is loaded first during the boot up process and remain in the system. There are some options that you can use with Linux pstree command. Below is the pstree synopsis taken from the pstree info page; :
SYNOPSIS pstree [-a] [-c] [-h|-Hpid] [-l] [-n] [-p] [-u] [-G|-U] [pid|user] pstree -V

The command pstree with -a option will show command line argument:
root@slackware:~# pstree -a init |-agetty 38400 tty2 linux

|-agetty 38400 tty3 |-agetty 38400 tty4 |-agetty 38400 tty5 |-agetty 38400 tty6 |-atd -b 15 -l 1 |-bash | `-pstree -a |-(bdflush) |-crond -l10 |-inetd |-(keventd) |-(khubd) |-(kjournald) |-klogd -c 3 -x |-(ksoftirqd_CPU0) |-(kswapd) |-(kupdated) |-(mdrecoveryd) |-sendmail |-sendmail |-sshd |-syslogd `-udevd root@slackware:~#

linux linux linux linux

The command pstree -p will show PID after process name:


root@slackware:~# pstree -p init(1)-+-agetty(354) |-agetty(355) |-agetty(356) |-agetty(357) |-agetty(358) |-atd(338) |-bash(353)---pstree(403) |-bdflush(5) |-crond(336) |-inetd(321) |-keventd(2) |-khubd(296) |-kjournald(11) |-klogd(63) |-ksoftirqd_CPU0(3) |-kswapd(4) |-kupdated(6) |-mdrecoveryd(10) |-sendmail(341) |-sendmail(344) |-sshd(325) |-syslogd(60) `-udevd(115) root@slackware:~#

The pstree command also support pipe. You can use pipe and less command to scroll a large output:
root@slackware:~# pstree -np | less

Linux top command


You can also view a dynamic real-time of a running process with command top. This is an example when you run top command:
top - 14:11:02 up 1:56, 2 users, load average: 0.00, 0.00, 0.00 Tasks: 25 total, 1 running, 24 sleeping, 0 stopped, 0 zombie Cpu(s): 0.0% user, 0.3% system, 0.0% nice, 99.7% idle Mem: 126500k total, 57148k used, 69352k free, 5280k buffers Swap: 497972k total, 0k used, 497972k free, 42888k cached PID USER 499 bill 1 root 2 root 3 root 4 root 5 root 6 root 10 root 11 root 60 root 63 root 115 root 296 root 321 root 325 root 336 root 338 daemon PR NI VIRT 16 0 1024 9 0 228 9 0 0 19 19 0 9 0 0 9 0 0 9 0 0 -1 -20 0 9 0 0 9 0 592 9 0 448 9 0 304 9 0 0 9 0 512 9 0 1516 8 0 620 9 0 664 RES 1024 228 0 0 0 0 0 0 0 592 448 304 0 512 1516 620 664 SHR 824 200 0 0 0 0 0 0 0 516 396 264 0 460 1260 536 576 S %CPU %MEM R 0.3 0.8 S 0.0 0.2 S 0.0 0.0 S 0.0 0.0 S 0.0 0.0 S 0.0 0.0 S 0.0 0.0 S 0.0 0.0 S 0.0 0.0 S 0.0 0.5 S 0.0 0.4 S 0.0 0.2 S 0.0 0.0 S 0.0 0.4 S 0.0 1.2 S 0.0 0.5 S 0.0 0.5 TIME+ 0:00.08 0:04.42 0:00.06 0:00.00 0:00.00 0:00.00 0:00.11 0:00.00 0:00.21 0:00.14 0:00.03 0:00.02 0:00.00 0:00.03 0:00.09 0:00.04 0:00.00 COMMAND top init keventd ksoftirqd_CPU0 kswapd bdflush kupdated mdrecoveryd kjournald syslogd klogd udevd khubd inetd sshd crond atd

That's some basic information about Linux process. Linux process is a very important topic and plays important role in Linux system. In the Stop and terminate hang program in Linux tutorial, you can see a real situation how ps command can be very useful in Linux administration task. Stop and terminate hang program in Linux There are two types of hang programs in Linux. The usual hang is in application level and the unusual hang is in kernel level which programmers called crash. We are not going to talk about crash now, perhaps in the future.

Why program hangs?


When you run or open a big database program, or maybe surf the Internet with lynx, one page to another, suddenly it stop responding. You wait for a moment, press an arrow keys, Enter, Esc, Ctrl+C, Ctrl+Z but to no avail, the program just freezes. What? Is the program hang? Program hang happens in Linux when a process get stuck waiting for something. It could be waiting for a process or resources to be free. What makes a program hang is the process or resource it is waiting is not available or busy. Some resources take some times to be free. The process is running slowly. The program is not hanged. Hang is real-time problem that one can analyze live the process. Another hang problem is deadlock. This happens when process A is waiting for process B to be free and process B is waiting for process A to be free.

Using Linux ps command


The Linux ps command which means process status is used to display live running processes on the system. What is a process? A process is called daemon in Linux. Every program that is running in the Linux system is a process. More information about ps command can be found in Linux administration Manage Linux process and daemons tutorial. Let's have some more practice with ps command to solve the Linux hang program. Login as a normal user. Run this command:
Welcome to Linux 2.6.27.7-smp (tty1) slackware login: bill Password: Linux 2.6.27.7-smp Last login: Sun Jun 21 11:42:55 +0800 2009 on tty4. No mail. bill@slackware:~$ vim & [1] 551 bill@slackware:~$ find / *.mpeg

The first command, vim & means we want to run the program in the background. Type the second command. When you press Enter, the result is running quite fast on the screen. Don't worry if you don't like this. Switch to second terminal by pressing Ctrl+Alt+F2. Login as another normal user and su to root. Let's try different ps command's option:
slackware login: luzar Password: Linux 2.6.27.7-smp Last login: Sun Jun 21 11:43:16 +0800 2009 on tty4. No mail. luzar@slackware:~$ su Password: root@slackware:~# ps PID TTY TIME CMD 585 tty2 00:00:00 bash 619 tty2 00:00:00 ps root@slackware:~# ps -a PID TTY TIME CMD 463 tty5 00:00:00 bash 551 tty1 00:00:00 vim 585 tty2 00:00:00 bash 629 tty2 00:00:08 updatedb 639 tty1 00:00:04 find 640 tty2 00:00:00 ps root@slackware:~# ps au USER PID %CPU %MEM VSZ RSS TTY STAT root 355 0.0 0.3 1392 476 tty3 Ss+ root 356 0.0 0.3 1392 476 tty4 Ss+ luzar 357 0.0 1.2 2704 1624 tty5 Ss root 359 0.0 0.3 1392 476 tty6 Ss+ root 463 0.0 1.2 2704 1620 tty5 S+ bill 541 0.0 1.2 2720 1632 tty1 Ss+ bill 551 0.0 2.3 10560 2952 tty1 T luzar 575 0.0 1.2 2700 1604 tty2 Ss root 585 0.0 1.2 2704 1612 tty2 S root 629 1.5 0.6 1652 808 tty2 T bill 639 86.8 0.5 1652 692 tty1 D+ root 641 0.0 0.6 2408 840 tty2 R+ root@slackware:~#

START 09:14 09:14 09:14 09:14 09:57 10:57 11:01 11:06 11:06 11:35 11:43 11:44

TIME 0:00 0:00 0:00 0:00 0:00 0:00 0:00 0:00 0:00 0:08 0:06 0:00

COMMAND /sbin/agetty 384 /sbin/agetty 384 -bash /sbin/agetty 384 -su -bash vim -bash -su updatedb find / *.mpg ps au

The first command, ps with no option prints out running processes in current terminal. The PID column is the Process ID. The TTY column indicates which terminal the process is running on. The TIME column indicates how much CPU time the process has been running and the CMD column shows the

command used. The second command ps -a, shows more details than ps alone. You can see currently running process in all terminals. The final command, ps au gives us more details plus some new columns. This time the USER column, %CPU column, %MEM column, VSZ column, RSS column, STAT column and START column added. Maybe you can guess the meaning of some of the new columns here. The important column is the STAT column which shows the status of the process. S stands for sleeping which means the process is waiting for something to happen. Z stands for a zombie process. A zombie process is one whose the parent process has died, leaving the child processes behind. You can stop these zombies processes. Check out detail information page with info ps command running in the Linux terminal.

Stop hang program with kill command


The commonly used command to stop a process is kill. You are going to use this command a lot in the future, yes, kill the misbehaved program, memory and cpu eating processes, hang programs, etc. Don't worry you're just a process killer ;-) We just learn how to view running process with ps. We are going to use all the informations above to kill off a process. Let's kill some processes in TTY1.
root@slackware:~# ps au | grep tty1 bill 541 0.0 1.2 2720 1632 bill 551 0.0 2.3 10560 2952 bill 713 69.0 0.5 1652 648 root 715 0.0 0.0 196 28 root@slackware:~# tty1 tty1 tty1 tty2 Ss T R+ R+ 10:57 11:01 12:47 12:47 0:00 0:00 0:02 0:00 -bash vim find / *.mpg grep tty1

The grep command is used to grab processes from tty1. To kill find process, check it's PID and issue the kill command with the following format: kill <PID>
root@slackware:~# kill 713 root@slackware:~# ps au | grep tty1 bill 541 0.0 1.2 2720 1640 bill 551 0.0 2.3 10560 2952 root 715 0.0 0.4 1688 596 root@slackware:~# tty1 tty1 tty2 Ss+ T S+ 10:57 11:01 12:57 0:00 0:00 0:00 -bash vim grep tty1

There's no more find process in the list, right? To force terminate a process, use kill with -9 option.
root@slackware:~# kill -9 root@slackware:~# ps au | bill 541 0.0 1.2 root 731 0.0 0.4 root@slackware:~# 551 grep tty1 2720 1640 1688 596 tty1 tty2 Ss+ S+ 10:57 13:04 0:00 0:00 -bash grep tty1

Switch to terminal 1 and check whether the process is still there:


/usr/lib/libgdbm.la /usr/lib/libgdbm.so /usr/lib/gdk-pixbuf

Terminated bill@slackware:~$ fg -bash: fg: job has terminated [1]+ Killed vim bill@slackware:~$

The program has been terminated. Ok that's good. Now switch back to terminal 2 and issue this command:
root@slackware:~# killall -9 bash Welcome to Linux 2.6.27.7-smp (tty2) slackware login:

You can use killall instead of kill to terminate all processes. The command killall kills all processes which share the same name. As you can see from the example above, program's name is used instead of pid. The basic syntax for Linux killall command is: killall [options] program_name(s) That's it. Like always, you can find more detail information with man and info commands. 2) Linux reboot command - Restart Linux system. Check out this Linux tutorial on how to bring down Linux system. Linux is a stable and reliable operating system. A properly setup Linux server can operates a whole year without a single restart. Software updates and patches doesn't need a system restart. A Linux server only need to be restart or shutdown only in certain circumstances such as hardware failure or hardware upgrade. Nowadays, Linux is not only a perfect choice for a server system but as a desktop computer as well. Ubuntu, openSUSE and Fedora are some of the popular choice to be installed on a desktop computer and a laptop computer. Even as a desktop operating system, Linux still doesn't need a restart during normal updates. But a normal desktop computer or a laptop doesn't need to be up 364 days a year. Here is a guide on how to bring down your Linux system, restart and shutdown.

Restart Linux system


In windows operating system, we use the term restart, which means to bring the operating system down and then start the operating system again. Normally the Windows operating system restart is needed to finished some tasks that you perform such as installing a new software or application or patched the operating system for security reason. In Linux environment, the term reboot is used instead of 'restart'. You can use 'reboot' command to restart Linux operating system. Just type reboot in the Linux command line and press enter. Of course you need to be root or have root privilege to reboot Linux system. See the reboot command example below which is run in Slackware command line terminal:
root@slackware:~# reboot

You can also use shutdown command to reboot your Linux system. Type 'shutdown -r now' and press Enter to reboot. See the command example below:
root@slackware:~# shutdown -r now

The '-r' option is for reboot. Another command to bring down your system is init. Init is the parent of all Linux processes. Its primary role is to create processes from a script stored in the file /etc/inittab. For more information about init, check system startup process tutorial. To restart a Slackware Linux using init, type init 6 at the command line. Below is an example of restart a Linux system using init command:
root@slackware:~$ init 6

However in the latest Ubuntu release, you can't find /etc/inittab anywhere. Below is a part of information about Ubuntu runlevel if you want to use init command:
The RUNLEVEL argument should be one of the multi-user runlevels 2-5, 0 to halt the system, 6 to reboot the system or 1 to bring the system down into single-user mode.

From the information above, we know that we can reboot Ubuntu system using init 6 command (the same as Slackware).

Power off Linux system


In Linux we say 'power off' a Linux system if we mean to completely shutdown our system. The Linux halt command is used to power off Linux operating system. Just like the Linux 'reboot' command, type 'halt' in the Linux command line terminal and press Enter. See halt command example below:
root@slackware:~# halt

Halt will stop the system after properly terminate all Linux processes. In some computers, halt automatically switch off computer power (complete shutdown) while on some other computers, you need to push the computer ON/OFF switch to power off. You can also use Linux shutdown command to power off your Linux system. We have seen shutdown command in the restart guide above. To power off a Linux system using 'shutdown' command, type shutdown -h now in the command line terminal and press Enter. See the example below:
root@slackware:~# shutdown -h now

The '-h' option is for halt. To power off Linux system using 'init', type init 0 at the command line. It's the same for Slackware Linux and Ubuntu. See command example below:
root@slackware:~$ init 0

Network tutorials
Introduction to Linux networking
This is a Linux networking section. Users have learned how to install Linux, practising a few basic Linux commands which enabled them to manage Linux system in the previous Linux basics and Linux administration tutorials. Here in the Linux networking section, user will be exposed to what Linux is all about, serving network. As you know, Linux itself is just a kernel. Linux can be configured as a networked workstation, a DNS server, a DHCP server, a web server, a mail server, a file and print server, database server, a firewall, a gateway router and many more. Is Linux can be all that? Yes it can. In this section, user will learn the true meaning of Linux, which is a network operating system or server system, to be all that mention above. The first thing you should learn about networking is ip addresses. A server and a client computer must have an ip address so that it can be reach in network environment. Learn about Linux ip address in Linux networking - ip address and subnet mask tutorial here.

ip address and subnet mask


Networking is essential when talking Linux into subject. As you already know, Linux derived from Unix which serve network as servers. So Linux user must have a basic knowledge about networking, especially the IP protocols and ethernet. IP protocol is one of the protocols that make a networking possible. What is a protocol? In a computer networking jargon, a protocol is a rules that govern communication between two systems. Like a language in human world which allows human to communicate with each other. So, ip protocol is a standard communication rules in computer networking. In order to understand each other, all operating system, Linux, windows, Unix, Mac OS must follow one rules or protocol. That's the brief desciption of ip protocol. Now you know that Internet uses the ip protocol :-) When talking about ip protocol, you should know the next subject which is ip address. Ip address is a unique address assigned to one network computer. This is important because a network computer must know which computer it is communicating with such as in client talking to a server situation. Ip address is divided into three classes which are class A, class B and class C. Next is subnet mask. Every time we assign an ip address to a network computer, we must also assign a subnet mask. Ip address comes with different subnet mask depending on it's class. In each ip classes, the subnet mask defines network segment of that system. It says how much of the address is used for the network is defined by the subnet mask. Ip address classes and subnet mask: Class A The decimal value of the first octet must be between 1 and 126. In a Class A address, the first octet is the network address and the last three octets are the node address. Therefore,

the default subnet mask is 255.0.0.0. Class B The decimal value of the first octet must be between 128 and 191. In a Class B address, the first two octets are the network address and the last two octets are the node address. Therefore, the default subnet mask is 255.255.0.0. Class C The decimal value of the first octet must be between 192 and 223. In a Class C address, the first three octets are the network address while the last octet is the node address. Therefore, the default subnet mask is 255.255.255.0. Linux server can serves networking 365 days a year without any problem. It's a proof that Linux is a very stable and secure network operating system when properly configured and maintained. All that starts with setting up a network card and configure an ip address for the server. The Linux networking Installing Ethernet card tutorial is a guide on how to install Ethernet card in Linux computer.

Installing Ethernet card


Ethernet card or more commonly known as network interface card is a required component if you want to connect to the network. Ethernet card is available in two version which are the PCI slot or the older ISA card. However, nowadays computer always comes with integrated Ethernet with motherboard. That's good, our Ethernet card can be the second network card. This is required if we want to configure our Linux to be a gateway router or a firewall later. Installing an Ethernet card 1. Power off your computer. 2. Open computer casing and Install your PCI Ethernet card in an available PCI expansion slot (an ISA card into ISA slot). 3. Close computer casing and plug in network cable into the Ethernet port and the other end into the router port (cat5 cable with rj45 socket) 4. Power on your computer. 5. Normally Linux will detect the Ethernet card and load appropriate kernel when you boot up the system. However if Linux doesn't detect it, you must manually configure the Etehrnet card by loading appropriate module using modprobe. 6. After Linux has finished boot up, check /etc/modprobe.conf (Slackware /etc/modprobe.d/modprobe.conf) that appropriate kernel has been loaded. 7. Type less /etc/modprobe.conf and verify that the alias eth0 has been created (and eth1 if you installed second Ethernet card). If not then you may need to manually edit this file and create the appropriate alias. If you dont, youll lose your networking configuration when the system reboots. When you 're done, then it time to configure the ip address for the Ethernet card. You already learned about ip address and installing a network interface card, now it's time to configure Linux ip address. Here is a guide on how to Setup Slackware Ethernet ip address.

Configure ip address
If you want to access Internet or your local network, you must have a network card (NIC). The drivers needed can be found in slackware/n3/netmods.tgz in your Slackware CD. If you installed all packages, then you must have the netmods package in your system already.

Linux network configuration


There are many network utilities in Linux that can be used to configure Ethernet ip address, netmask, routing table, name server and so on. Below are essential Linux commands used to configure Linux ip address.

Linux ifconfig command


The Linux ifconfig command can be used to configure a network interface card or Ethernet card. If the Linux ifconfig command issued without any argument or option, it displays the status of the currently active interfaces. See part of ifconfig manual page below:
NAME ifconfig - configure a network interface SYNOPSIS ifconfig [-v] [-a] [-s] [interface] ifconfig [-v] interface [aftype] options | address ... DESCRIPTION Ifconfig is used to configure the kernel-resident network interfaces. It is used at boot time to set up interfaces as necessary. After that, it is usually only needed when debugging or when system tuning is needed. If no arguments are given, ifconfig displays the status of the currently active interfaces. If a single interface argument is given, it displays the status of the given interface only; if a single -a argument is given, it displays the status of all interfaces, even those that are down. Otherwise, it configures an interface.

Here is a complete usage syntax:


Usage: ifconfig [-a] [-v] [-s] <interface> [[<AF>] <address>] [add <address>[/<prefixlen>]] [del <address>[/<prefixlen>]] [[-]broadcast [<address>]] [[-]pointopoint [<address>]] [netmask <address>] [dstaddr <address>] [tunnel <address>] [outfill <NN>] [keepalive <NN>] [hw <HW> <address>] [metric <NN>] [mtu <NN>] [[-]trailers] [[-]arp] [[-]allmulti] [multicast] [[-]promisc] [mem_start <NN>] [io_addr <NN>] [irq <NN>] [media <type>] [txqueuelen <NN>] [[-]dynamic] [up|down] ... <HW>=Hardware Type. List of possible hardware types:

loop (Local Loopback) slip (Serial Line IP) cslip (VJ Serial Line IP) slip6 (6-bit Serial Line IP) cslip6 (VJ 6-bit Serial Line IP) adaptive (Adaptive Serial Line IP) strip (Metricom Starmode IP) ash (Ash) ether (Ethernet) tr (16/4 Mbps Token Ring) tr (16/4 Mbps Token Ring (New)) ax25 (AMPR AX.25) netrom (AMPR NET/ROM) rose (AMPR ROSE) tunnel (IPIP Tunnel) ppp (Point-to-Point Protocol) hdlc ((Cisco)-HDLC) lapb (LAPB) arcnet (ARCnet) dlci (Frame Relay DLCI) frad (Frame Relay Access Device) sit (IPv6-in-IPv4) fddi (Fiber Distributed Data Interface) hippi (HIPPI) irda (IrLAP) ec (Econet) x25 (generic X.25) eui64 (Generic EUI-64) <AF>=Address family. Default: inet List of possible address families: unix (UNIX Domain) inet (DARPA Internet) inet6 (IPv6) ax25 (AMPR AX.25) netrom (AMPR NET/ROM) rose (AMPR ROSE) ipx (Novell IPX) ddp (Appletalk DDP) ec (Econet) ash (Ash) x25 (CCITT X.25)

See ifconfig command invoke with no option example below:


root@slackware:~# ifconfig eth0 Link encap:Ethernet HWaddr 00:aa:11:bb:22:cc inet addr:10.10.0.6 Bcast:10.21.35.255 Mask:255.255.0.0 UP BROADCAST RUNNING MULTICAST MTU:1500 Metric:1 RX packets:0 errors:0 dropped:0 overruns:0 frame:0 TX packets:0 errors:0 dropped:0 overruns:0 carrier:0 collisions:0 txqueuelen:1000 RX bytes:0 (0.0 b) TX bytes:0 (0.0 b) Interrupt:11 Base address:0x1080 lo Link encap:Local Loopback inet addr:127.0.0.1 Mask:255.0.0.0 UP LOOPBACK RUNNING MTU:16436 Metric:1 RX packets:0 errors:0 dropped:0 overruns:0 frame:0 TX packets:0 errors:0 dropped:0 overruns:0 carrier:0 collisions:0 txqueuelen:0 RX bytes:0 (0.0 b) TX bytes:0 (0.0 b)

The first paragraph above shows the first Ethernet card, eth0 configuration. The line in red shows Ethernet ip address, broadcast and netmask. The second paragraph shows localhost or loopback configuration. This is an example on how to use ifconfig command to setup a new Linux ip address for the first Ethernet card:
root@slackware:~# ifconfig eth0 192.168.1.5 netmask 255.255.255.0 up

Linux route command


After setting up a Linux ip address with ifconfig command, use Linux route command to set up static routes to specific hosts or networks. Linux route command is a tool where you can setup where to send which data. Basically you can use route command to show and manipulate routing table. This is an example of how to use route command in Linux. Issue route command without any option will print current routing table. To add a new ip route via eth0 (first Ethernet card), issue route add command in this format: route add -net <ip> netmask <ip> dev eth0
root@slackware:~# route add -net 192.168.1.0 netmask 255.255.255.0 dev eth0

You can also add a gateway of the network: route add -net <ip> gw <ip> netmask <ip> dev eth0
root@slackware:~# route add -net 192.168.1.0 gw 192.168.1.1 netmask 255.255.255.0 dev eth0

Now, check the routing table again:


root@slackware:~# route Kernel IP routing table Destination Gateway 192.168.1.0 * loopback * default 192.168.1.1 root@slackware:~# Genmask 255.255.255.0 255.0.0.0 0.0.0.0 Flags U U UG Metric 0 0 1 Ref 0 0 0 Use 0 0 0 Iface eth0 lo eth0

We can see all configurations we made is in the result above.

Slackware netconfig
In Slackware, a setup program called netconfig is very easy to use and very helpful for a beginner to setup Linux ip address including basic network configuration. Lets try it. You must login as root because as a normal user, you dont have power to configure network. From root command prompt, type netconfig and Enter. You'll have a screen like this:

Enter your hostname for example linuxserver. Move to <ok> by using the Tab key, Enter to continue.

Now you must provide a domain name for your host. Enter your domain name. When you finished, press Enter to continue.

Well learn how to set up static IP address now. Use arrow key to move up and down. Choose Static IP and Enter. On the next screen, you have to provide an IP address. Enter your IP address and Enter to continue.

Now Enter the netmask.

Enter your gateway IP address. If you dont have any gateway yet, or you are planning to use this

server as a gateway, then use the same IP address.

Youll be asked whether you will be accessing a name server. The name server here means your DNS server address or your ISP DNS ip address.

Enter your name server ip address. If you are using name server, you can enter it here

In this screen, you have to confirm your network setup. Move up and down using arrow key. If you want to edit something, you can do it now, and Tab to edit and Enter.

When you are done, Tab to Accept and Enter. If you accept the setting, Enter one more time to confirm. Thats it, you are done. You will have the root command prompt again.

Type clear at the root command prompt to clear the screen. Normally, the ifconfig command is used to configure network interface card. Slackware make our job easier with netconfig. However, ifconfig is still an important Linux command. The ifconfig command can be used to check our Linux network configuration. Let's confirm what weve done above with ifconfig command. Type 'ifconfig' and enter as example below:
root@slackware:~# ifconfig lo Link encap:Local Loopback inet addr:127.0.0.1 Mask:255.0.0.0 UP LOOPBACK RUNNING MTU:16436 Metric:1 RX packets:0 errors:0 dropped:0 overruns:0 frame:0 TX packets:0 errors:0 dropped:0 overruns:0 carrier:0 collisions:0 txqueuelen:0 RX bytes:0 (0.0 b) TX bytes:0 (0.0 b) root@slackware:~#

Check the inet addr and Mask. What? We still have the old data? Don't worry, keep on reading.

Stop and start linux service


So now we must update the Linux network configuration data that we setup with netconfig just now. What we have to do is restart the service which means stop and start the service again. Remember

about /etc/rc.d directory? The service we want to restart is rc.inet1. This is the complete command to stop and start a service:
root@slackware:~# /etc/rc.d/rc.inet1 stop root@slackware:~# /etc/rc.d/rc.inet1 start root@slackware:~# ifconfig eth0 Link encap:Ethernet HWaddr 00:aa:11:bb:22:cc inet addr:192.168.1.5 Bcast:192.168.1.255 Mask:255.255.255.0 UP BROADCAST RUNNING MULTICAST MTU:1500 Metric:1 RX packets:0 errors:0 dropped:0 overruns:0 frame:0 TX packets:0 errors:0 dropped:0 overruns:0 carrier:0 collisions:0 txqueuelen:1000 RX bytes:0 (0.0 b) TX bytes:0 (0.0 b) Interrupt:11 Base address:0x1080 lo Link encap:Local Loopback inet addr:127.0.0.1 Mask:255.0.0.0 UP LOOPBACK RUNNING MTU:16436 Metric:1 RX packets:0 errors:0 dropped:0 overruns:0 frame:0 TX packets:0 errors:0 dropped:0 overruns:0 carrier:0 collisions:0 txqueuelen:0 RX bytes:0 (0.0 b) TX bytes:0 (0.0 b)

root@slackware:~#

You can also use '/etc/rc.d/rc.inet1 restart' command to do the above task.

Setup and configure a second network card


If we have another network card in the computer, then we can configure it now. However we can't use netconfig anymore. The netconfig tool is used to configure Linux ip address for the first network card. For the second network card, we can setup ip address by manually edit the /etc/rc.d/rc.inet1.conf file. Open the file with text editor, such as vim and in the eth1 section (a second network card), add your network configuration data. Also, you should add HWADDR data, which is the mac address of the network card because we don't want the eth0 and eth1 swap every time we reboot Linux. The 'HWADDR' data is unique. To see check what your mac address is, use ifconfig command as in the ifconfig example above. Write the address and then open /etc/rc.d/rc.inet1.conf file with text editor. See example below:
# # # # # /etc/rc.d/rc.inet1.conf This file contains the configuration settings for network interfaces. If USE_DHCP[interface] is set to "yes", this overrides any other settings. If you don't have an interface, leave the settings null ("").

# You can configure network interfaces other than eth0,eth1... by setting # IFNAME[interface] to the interface's name. If IFNAME[interface] is unset # or empty, it is assumed you're configuring eth. # Several other parameters are available, the end of this file contains a # comprehensive set of examples. # ============================================================================= # Config information for eth0: IPADDR[0]="192.168.1.5" NETMASK[0]="255.255.255.0" HWADDR[0]="00:aa:11:bb:22:cc" USE_DHCP[0]="" DHCP_HOSTNAME[0]=""

# Config information for eth1: IPADDR[1]="192.168.2.1" NETMASK[1]="255.255.255.0" HWADDR[1]="33:aa:44:bb:55:cc" USE_DHCP[1]="" DHCP_HOSTNAME[1]=""

That's it, save the file and restart rc.inet1 daemon. Run the 'ifconfig' command to update the new network card data.
root@slackware:~# ifconfig eth0 Link encap:Ethernet HWaddr 00:aa:11:bb:22:cc inet addr:192.168.1.5 Bcast:192.168.1.255 Mask:255.255.255.0 inet6 addr: fe80::223:cdff:feb4:9f1f/64 Scope:Link UP BROADCAST RUNNING MULTICAST MTU:1500 Metric:1 RX packets:1895974 errors:0 dropped:28 overruns:0 frame:0 TX packets:411289 errors:0 dropped:0 overruns:0 carrier:0 collisions:0 txqueuelen:1000 RX bytes:674815483 (643.5 MiB) TX bytes:73677358 (70.2 MiB) Interrupt:17 Base address:0xe800 eth1 Link encap:Ethernet HWaddr 33:aa:44:bb:55:cc inet addr:192.168.2.1 Bcast:192.168.2.255 Mask:255.255.255.0 inet6 addr: fe80::21b:fcff:fed3:e47f/64 Scope:Link UP BROADCAST RUNNING MULTICAST MTU:1500 Metric:1 RX packets:332574 errors:0 dropped:35 overruns:0 frame:0 TX packets:470231 errors:0 dropped:0 overruns:0 carrier:8 collisions:0 txqueuelen:1000 RX bytes:64241167 (61.2 MiB) TX bytes:498941589 (475.8 MiB) Link encap:Local Loopback inet addr:127.0.0.1 Mask:255.0.0.0 inet6 addr: ::1/128 Scope:Host UP LOOPBACK RUNNING MTU:16436 Metric:1 RX packets:18 errors:0 dropped:0 overruns:0 frame:0 TX packets:18 errors:0 dropped:0 overruns:0 carrier:0 collisions:0 txqueuelen:0 RX bytes:980 (980.0 B) TX bytes:980 (980.0 B)

lo

root@slackware:~#

Linux ping command


The ping command is famous not only in Linux system but windows as well. Normally, it is used to check network connection between two hosts. However, ping offers many options in Linux. The ping manual is a good tutorial, make sure you read it. Ok now let's check our network interface with ping. We can try pinging our gateway router if we already in the network but if in standalone pc, ping our own NIC just for practice and look how things work. The ping format is ping <option> <target ip>:
root@slackware:~# ping -c3 192.168.1.5 PING 192.168.1.5 (192.168.1.5) 56(84) bytes of data. 64 bytes from 192.168.1.5: icmp_seq=1 ttl=64 time=0.200 ms 64 bytes from 192.168.1.5: icmp_seq=2 ttl=64 time=0.287 ms 64 bytes from 192.168.1.5: icmp_seq=3 ttl=64 time=0.290 ms

--- 192.168.1.5 ping statistics --3 packets transmitted, 3 received, 0% packet loss, time 1998ms rtt min/avg/max/mdev = 0.200/0.259/0.290/0.041 ms root@slackware:~#

In the example above, we use ping command with -c3 which means we ping to count and print output three times only. During this period of learning, understanding of Linux command structure and syntax is necessary. Setting up and configuring Linux network requires testing and troubleshooting. You might encounter errors, which is most likely, and try to troubleshoot by analysing error log files. You can learn and practice Linux network commands in Linux network commands tutorial.

Linux network commands


Linux, which is based on Unix, is a network operating system. It means, Linux is an operating system designed to served end user systems such as workstation and personal computer. Linux also provide other important network services including printer sharing, database sharing, ftp, routing, security and so on. In this tutorial, user will learn from basic network configuration which is configuring network interface card to the advanced server configuration. Linux ifconfig command Configure a network interface using Linux ifconfig command. This tutorial covers options normally used with ifconfig to configure network.

Configure Linux ip address with ifconfig command


Linux ifconfig command is used to setup a network interface card (NIC). It means we can use ifconfig command to configure ip address, netmask and gateway for the card. The ifconfig command is also used to configure or tuning the network interface card such as changing the ip address or assigning ip alias, protocol, parameter and other options. We can also use ifconfig command to view network interface card's status and to activate or deactivate the interface driver. User need to have root privileged in order to use the ifconfig command. So, switch to root by issuing su command. For a Ubuntu Linux add a sudo before the ifconfig command. ifconfig's syntax to configure ip address, netmask and to activate or deactivate network interface card: ifconfig <interface> <ip address> netmask <netmask ip> up/down Where: <interface> = Network interface card (eth0, eth1, etc) <ip address> = NIC ip address (i.e. 192.168.1.5) <netmask ip> = netmask ip (i.e. 255.255.255.0) up/down = Choose up to activate and down to deactivate. Example:

ifconfig eth0 192.168.1.5 netmask 255.255.255.0 up

Simple way to configure Linux ip address


ifconfig's syntax: ifconfig [interface] [ip address] [option] Use ifconfig command to change ip address of the first network interface card example: ifconfig eth0 192.168.1.5 Use ifconfig command to change ip address of the second network interface card example: ifconfig eth1 10.21.35.5 Use ifconfig command to change netmask of the first network interface card example: ifconfig eth0 netmask 255.255.255.0 Use ifconfig command to change netmask of the second network interface card example: ifconfig eth0 netmask 255.255.255.0 Example on how to bring up the first network interface card using Linux ifconfig command: ifconfig eth0 192.168.1.5 up Example on how to bring down the first network interface card using Linux ifconfig command: ifconfig eth0 down If users want to see ifconfig in action, visit Linux basic network configuration. Please check Linux ifconfig manual page using 'man ifconfig' command to see more details. Linux netstat command Use Linux netstat command to list network connections, view routing table and gain information about network interface.

netstat command tutorial


Linux netstat command is another useful network utility in Linux. We can use netstat to list network connections, view routing table and information about network interface. The netstat command has been one of useful tools for network troubleshooting. This tutorial is a basic guide to the netstat command with usage examples to help the new Linux beginner.

Linux netstat command examples


The syntax for netstat command is: netstat <option> Below are the common options used with netstat command:
a i l s r Lists all listening and non-listening sockets. Displays statistics for your network interfaces. Lists listening sockets. Displays summary information for each protocol. Displays your routing table.

Lists all listening and non-listening sockets using netstat command with -a option:
root@slackware:~# netstat -a Active Internet connections (servers and established) Proto Recv-Q Send-Q Local Address Foreign Address tcp 0 0 *:time *:* tcp 0 0 *:netbios-ssn *:* tcp 0 0 *:auth *:* tcp 0 0 slackware.example.c:domain *:* tcp 0 0 localhost:domain *:* tcp 0 0 *:ssh *:* tcp 0 0 localhost:rndc *:* tcp 0 0 *:microsoft-ds *:* tcp 0 52 slackware.example.com:ssh 192.168.1.6:1320 tcp6 0 0 [::]:ssh [::]:* tcp6 0 0 ::1%8191:rndc [::]:* ... ... ... State LISTEN LISTEN LISTEN LISTEN LISTEN LISTEN LISTEN LISTEN ESTABLISHED LISTEN LISTEN

Displays statistics for Linux network interfaces using netstat command with -i option:
root@slackware:~# netstat -i Kernel Interface table Iface MTU Met RX-OK RX-ERR RX-DRP RX-OVR eth0 1500 0 156 0 0 0 lo 16436 0 17 0 0 0 root@slackware:~# TX-OK TX-ERR TX-DRP TX-OVR Flg 128 0 0 0 BMRU 17 0 0 0 LRU

Lists listening sockets using netstat command with -l option:


root@slackware:~# netstat -l Active Internet connections (only servers) Proto Recv-Q Send-Q Local Address Foreign Address State tcp 0 0 *:time *:* LISTEN tcp 0 0 *:netbios-ssn *:* LISTEN tcp 0 0 *:auth *:* LISTEN tcp 0 0 slackware.example.c:domain *:* LISTEN tcp 0 0 localhost:domain *:* LISTEN tcp 0 0 *:ssh *:* LISTEN tcp 0 0 localhost:rndc *:* LISTEN tcp 0 0 *:microsoft-ds *:* LISTEN tcp6 0 0 [::]:ssh [::]:* LISTEN tcp6 0 0 ::1%8191:rndc [::]:* LISTEN udp 0 0 *:biff *:* udp 0 0 slackware.examp:netbios-ns *:* udp 0 0 *:netbios-ns *:* udp 0 0 slackware.exam:netbios-dgm *:* udp 0 0 *:netbios-dgm *:* udp 0 0 *:time *:* udp 0 0 *:48176 *:* udp 0 0 slackware.example.c:domain *:* udp 0 0 localhost:domain *:* udp6 0 0 [::]:50273 [::]:* Active UNIX domain sockets (only servers) Proto RefCnt Flags Type State I-Node Path unix 2 [ ACC ] STREAM LISTENING 7941 /dev/gpmctl unix 2 [ ACC ] STREAM LISTENING 7064 @/var/run/hald/dbus-hPhDf9IKkl unix 2 [ ACC ] STREAM LISTENING 7067 @/var/run/hald/dbus-QrEWsdl4tf unix 2 [ ACC ] STREAM LISTENING 7037 /var/run/dbus/system_bus_socket unix 2 [ ACC ] STREAM LISTENING 7003 /var/run/acpid.socket root@slackware:~#

Displays summary information for each protocol using netstat command with -s option:
root@slackware:~# netstat -s Ip: 263 total packets received 0 forwarded 0 incoming packets discarded 243 incoming packets delivered 210 requests sent out Icmp: 5 ICMP messages received 0 input ICMP message failed. ICMP input histogram: destination unreachable: 3 echo replies: 2 2 ICMP messages sent 0 ICMP messages failed ICMP output histogram: echo request: 2 IcmpMsg: InType0: 2 InType3: 3 OutType8: 2 Tcp: 2 active connections openings 1 passive connection openings 2 failed connection attempts 0 connection resets received 1 connections established 175 segments received 152 segments send out 0 segments retransmited 0 bad segments received. 2 resets sent Udp: 63 packets received 0 packets to unknown port received. 0 packet receive errors 56 packets sent UdpLite: TcpExt: 1 delayed acks further delayed because of locked socket 1 packets directly queued to recvmsg prequeue. 1 bytes directly received in process context from prequeue 24 packet headers predicted 95 acknowledgments not containing data payload received 2 predicted acknowledgments IpExt: InBcastPkts: 37 OutBcastPkts: 25 root@slackware:~#

Displays Linux routing table using netstat command with -r option: root@slackware:~# netstat -r Kernel IP routing table Destination Gateway Genmask Flags MSS Window irtt Iface localnet * 255.255.255.0 U 0 0 0 eth0 loopback * 255.0.0.0 U 0 0 0 lo default 192.168.1.1 0.0.0.0 UG 0 0 0 eth0 root@slackware:~# Linux route command Linux route command manipulate the IP routing table. Check out this tutorial to learn more about route command.

Linux route command description and examples


Besides Linux ifconfig command, the Linux route command is another important network commands every Linux user should know. The route command can be used to add or modify a static route and a default gateway in the Linux or Unix system. As specify in the Linux Programmer's Manual, Linux route command shows or manipulate the IP routing table. The IP stated is the Internet Protocol (ip address, netmask, gateway) which has been set during configuring network interface card (NIC) in the Linux ifconfig tutorial earlier. The Linux route command comes with many options but most network administrators familiar with add and del options. The route add command is used to add a new route while the route del command is to delete a route. The route add syntax: route add -net < ip address > netmask < netmask ip > dev < interface > Where:
< ip address > is network interface card ip address < netmask ip > ip netmask such 255.255.255.0 Interface = eth0, eth1, eth2, etc

The route del syntax: route del -net < ip address > netmask < netmask ip > dev <interface > Where:
<ip address > is network interface card ip address <netmask ip > ip netmask such 255.255.255.0 Interface = eth0, eth1, eth2, etc

Here is an example of Linux route command in action: Linux basic network configurations. Below is a complete manual when issuing the man route command in the command line terminal. Do remember that in order to use route command you must have root privilege.
ROUTE(8) NAME route - show / manipulate the IP routing table SYNOPSIS route [-CFvnee] route [-v] [-A family] add [-net|-host] target [netmask Nm] [gw Gw] [metric N] [mss M] [window W] [irtt I] [reject] [mod] [dyn] [reinstate] [[dev] If] [-v] [-A family] del [-net|-host] target [gw Gw] [netmask Nm] [metric N] [[dev] If] [-V] [--version] [-h] [--help] Linux Programmer's Manual ROUTE(8)

route route

DESCRIPTION Route manipulates the kernel's IP routing tables. Its primary use is to set up static routes to specific hosts or networks via an interface after it has been configured with the ifconfig(8) program. When the add or del options are used, route modifies the routing tables. Without these options, route displays the current contents of the routing tables.

OPTIONS -A family use the specified address family (eg `inet'; use `route for a full list). -F

--help'

operate on the kernel's FIB (Forwarding Information Base) routing table. This is the default. -C -v -n show numerical addresses instead of trying to determine symbolic host names. This is useful if you are trying to determine why the route to your nameserver has vanished. -e use netstat(8)-format for displaying the routing table. -ee will generate a very long line with all parameters from the routing table. delete a route. add a new route. the destination network or host. You can provide IP addresses in dotted decimal or host/network names. -net -host the target is a network. the target is a host. operate on the kernel's routing cache. select verbose operation.

del add target

netmask NM when adding a network route, the netmask to be used. gw GW route packets via a gateway. NOTE: The specified gateway must be reachable first. This usually means that you have to set up a static route to the gateway beforehand. If you specify the address of one of your local interfaces, it will be used to decide about the interface to which the packets should be routed to. This is a BSDism compatibility hack. dae-

metric M set the metric field in the routing table (used by routing mons) to M. mss M set the TCP Maximum Segment Size (MSS) for connections over this route to M bytes. The default is the device MTU minus headers, or a lower MTU when path mtu discovery occured. This setting can be used to force smaller TCP packets on the other end when path mtu discovery does not work (usually because of misconfigured firewalls that block ICMP Fragmentation Needed)

window W set the TCP window size for connections over this route to W bytes. This is typically only used on AX.25 networks and with drivers unable to handle back to back frames. irtt I set the initial round trip time (irtt) for TCP connections over

this route to I milliseconds (1-12000). This is typically only used on AX.25 networks. If omitted the RFC 1122 default of 300ms is used. reject install a blocking route, which will force a route lookup to fail. This is for example used to mask out networks before using the default route. This is NOT for firewalling. mod, dyn, reinstate install a dynamic or modified route. These flags are for diagnostic purposes, and are generally only set by routing daemons. dev If force the route to be associated with the specified device, as the kernel will otherwise try to determine the device on its own (by checking already existing routes and device specifications, and where the route is added to). In most normal networks you won't need this. If dev If is the last option on the command line, the word dev may be omitted, as it's the default. Otherwise the order of the route modifiers (metric - netmask - gw - dev) doesn't matter. EXAMPLES route add -net 127.0.0.0 adds the normal loopback entry, using netmask 255.0.0.0 (class A net, determined from the destination address) and associated with the "lo" device (assuming this device was prviously set up correctly with ifconfig(8)). route add -net 192.56.76.0 adds a route to the netmask modifier is Class C IP address. netmask 255.255.255.0 dev eth0 network 192.56.76.x via "eth0". The Class C not really necessary here because 192.* is a The word "dev" can be omitted here.

route add default gw mango-gw adds a default route (which will be used if no other route matches). All packets using this route will be gatewayed through "mango-gw". The device which will actually be used for that route depends on how we can reach "mango-gw" - the static route to "mango-gw" will have to be set up before. route add ipx4 sl0 Adds the route to the "ipx4" host via the SLIP interface (assuming that "ipx4" is the SLIP host). route add -net 192.57.66.0 netmask 255.255.255.0 gw ipx4 This command adds the net "192.57.66.x" to be gatewayed through the former route to the SLIP interface. route add -net 224.0.0.0 netmask 240.0.0.0 dev eth0 This is an obscure one documented so people know how to do it. This sets all of the class D (multicast) IP routes to go via "eth0". This is the correct normal configuration line with a multicasting kernel. route add -net 10.0.0.0 netmask 255.0.0.0 reject This installs a rejecting route for "10.x.x.x." OUTPUT The output of the kernel routing table is organized in the following columns the private network

Destination The destination network or destination host. Gateway The gateway address or '*' if none set. Genmask The netmask for the destination net; '255.255.255.255' for a host destination and '0.0.0.0' for the default route. Flags Possible flags include U (route is up) H (target is a host) G (use gateway) R (reinstate route for dynamic routing) D (dynamically installed by daemon or redirect) M (modified from routing daemon or redirect) A (installed by addrconf) C (cache entry) ! (reject route) The 'distance' to the target (usually counted in hops). It is not used by recent kernels, but may be needed by routing daemons. Ref Use Iface MSS Number of references to this route. (Not used in the Linux nel.) ker-

Metric

Count of lookups for the route. Depending on the use of -F and -C this will be either route cache misses (-F) or hits (-C). Interface to which packets for this route will be sent. Default maximum segement size this route. for TCP connections over

Window Default window size for TCP connections over this route. irtt Initial RTT (Round Trip Time). The kernel uses this to guess about the best TCP protocol parameters without waiting on (possibly slow) answers.

HH (cached only) The number of ARP entries and cached routes that refer to the hardware header cache for the cached route. This will be -1 if a hardware address is not needed for the interface of the cached route (e.g. lo). Arp (cached only) Whether or not the hardware address for the cached route is up to date. FILES /proc/net/ipv6_route /proc/net/route /proc/net/rt_cache SEE ALSO ifconfig(8), netstat(8), arp(8), rarp(8) HISTORY Route for Linux was originally written by Fred and then modified by Johannes Stille N. van Kempen,

and Linus Torvalds for pl15. Alan Cox added the mss and window options for Linux 1.1.22. irtt support and merged with netstat from Bern Eckenfels. AUTHOR Currently maintained by Phil Blundell . net-tools 2 January 2000 ROUTE(8)

Linux ping command Send ICMP ECHO_REQUEST to network hosts is what Linux ping command does. Learn different options that can be used with ping command.

Linux ping command


The ping command is famous not only in Linux system but windows as well. Normally, it is used to check network connection between two hosts. However, ping offers many options in Linux. The ping manual is a good tutorial, make sure you read it. Ok now let's check our network interface with ping. We can try pinging our gateway router if we already in the network but if in standalone pc, ping our own NIC just for practice and look how things work. The ping format is ping <option> <target ip>:
root@slackware:~# ping -c3 192.168.1.5 PING 192.168.1.5 (192.168.1.5) 56(84) bytes of data. 64 bytes from 192.168.1.5: icmp_seq=1 ttl=64 time=0.200 ms 64 bytes from 192.168.1.5: icmp_seq=2 ttl=64 time=0.287 ms 64 bytes from 192.168.1.5: icmp_seq=3 ttl=64 time=0.290 ms --- 192.168.1.5 ping statistics --3 packets transmitted, 3 received, 0% packet loss, time 1998ms rtt min/avg/max/mdev = 0.200/0.259/0.290/0.041 ms root@slackware:~#

In the example above, we use ping command with -c3 which means we ping to count and print output three times only. Linux telnet command Communicate with another host using the telnet protocol. Probably telnet is one of those terms that most users are familiar with.

Linux telnet command guides


Telnet is the most known remote login server. Perhaps all computer background people familiar with telnet, at least to check server networking status (that's what network officers at my place do anyway!). However, in this tutorial we are going to do more than that.

Configure telnet server


Now let's take a closer look at the Linux telnet program itself. Normally telnet comes with all major Linux distributions. In Slackware Linux, the telnet daemon can be enabled in the super server, inetd (xinetd in Redhat and Fedora). At the command, type vim /etc/inetd.conf to activate telnet server. It's the same for other Linux distributions except for system V based distributions such as Redhat Linux and Fedora Linux.
root@slackware:~$ vim /etc/inetd.conf

Looking for # Telnet server like in the figure below:


# Telnet server: # telnet stream # tcp nowait root /usr/sbin/tcpd in.telnetd

Now remove # at the beginning line of the script by pressing x key on the keyboard to activate telnet server. Exit and save the inetd.conf file with command ':wq'. Restart the super server with command below:
root@slackware:~$ /etc/rc.d/rc.inetd restart

Using Linux telnet program


We have finish setting up the Linux telnet server in Slackware Linux. Let's testing the telnet server now. Please take note that in order to use the telnet program, we must have a network connection and a client computer, it doesn't matter whether Linux or windows installed. Remember that we use telnet to remotely manage a server. To run a telnet program on windows computer, open command prompt by clicking on Start --> Run and type 'cmd'. Type telnet at the command prompt and press Enter. You should have something like the example figure below. This is a Microsoft Telnet Client.
Welcome to Microsoft Telnet Client Escape Character is 'CTRL+]' Microsoft Telnet>

Let's see what command can we use in telnet program. Type 'help' and Enter.
ftp> help Commands may be abbreviated. Commands are: c - close close current connection d - display display operating parameters o - open hostname [port] connect to hostname (default port 23). q - quit exit telnet set - set set options (type 'set ?' for a list) sen - send send strings to server st - status print status information u - unset unset options (type 'unset ?' for a list) ?/h - help print help information Microsoft Telnet>

So we can see that the command 'o' is used to open a connection to hostname. Type 'o' <hostname ip address> and press Enter:
Welcome to Microsoft Telnet Client Escape Character is 'CTRL+]' Microsoft Telnet> o 192.168.0.5

If there is no problem with the network and port 23 for telnet is open, you'll get login prompt for the remote machine. Now that you already connected to the remote machine, login as usual, provide your account name and password. See telnet login example below:
Welcome to Linux 2.4.29 (tty1) login: labu Password: [labu@slackware labu]$

Basic ftp command User interface to the Internet standard File Transfer Protocol aka ftp. Learn more about ftp, configure ftp server, client and regular used ftp commands.

Linux ftp tutorial - ftp client guides


What is FTP?
FTP stands for file transfer protocol. It is widely used as file transfer protocol in the Internet and file sharing in local networks such as in university, business and organizations around the world. Basically, ftp allows data sharing in a networking environment. It is a client-server concept, where an ftp server serves all clients in the network. Although we can send and receive file using email attachment, but the fact that email only allows small size attachment has made ftp a popular protocol to transfer files. In Linux environment, ftp is very important because many task and application use ftp protocol such as Linux package management system. Another example of ftp important usage is transfering large web site files to the web server. A standard ftp port is port 21. You can check ftp port using telnet command to make sure it's open or not. The command syntax is telnet domain-name 21. You can also use ip address and replace domainname. Here is the example on how to check ftp port 21 using telnet command:
luzar@slackware:~$ telnet slackware.example.com 21 Trying 192.168.0.3... Connected to slackware.example.com. Escape character is '^]'. 220---------- Welcome to Pure-FTPd [TLS] ---------220-You are user number 2 of 50 allowed. 220-Local time is now 21:35. Server port: 21. 220-This is a private system - No anonymous login 220-IPv6 connections are also welcome on this server. 220 You will be disconnected after 15 minutes of inactivity. quit 221-Goodbye. You uploaded 0 and downloaded 0 kbytes. 221 Logout.

The example shows the server port 21 is open and not blocked by firewall. When using telnet command to check ftp port, we use 'quit' commmand to exit from telnet. To download files and upload files to the ftp server, we are going to use a proper ftp client.

Linux ftp client


If you are using Slackware Linux, you can use gftp, which is a gui ftp client program comes by default installation in KDE. If you are using Ubuntu desktop, you can also install gftp in gnome. Here is gftp program information:
gFTP is a multithreaded FTP client. This version of it runs under X and was written using GLib/GTK+. gFTP features: * simultaneous downloads, * resuming of interrupted file transfers, * file transfer queues, * downloading of entire directories, * FTP and HTTP proxy support, * remote directory caching, * passive and non-passive file transfers, * drag-n-drop support, * bookmarks menu, * support for SSH and SSH2 file transfers, * support FXP transfers, * stop button, and many more features. Author: Brian Masney Homepage: http://www.gftp.org/

There are other free ftp client programs that you can install in Linux such as:

Java GUI client for FTP, SMB, SFTP and NFS


JFtp is a graphical Java network and file transfer client. It supports FTP using its own FTP API and various other protocols like SMB, SFTP, NFS, HTTP, and file I/O using third party APIs. It includes many advanced features such as recursive directory up/download, browsing FTP servers while transferring files, FTP resuming and queueing, browsing the LAN for Windows shares, and more. Multiple connections can open at a time in a Mozilla-style tabbed browsing environment. Homepage: http://j-ftp.sourceforge.net

KFTPGrabber ftp client for KDE


KFTPgrabber is a graphical FTP client for the K Desktop Environment. It implements many features required for usable FTP interaction. Feature list:
* * * * * * * * * * * * * * * * * * Multiple simultaneous FTP sessions in separate tabs A tree-oriented transfer queue TLS/SSL support for the control connection and the data channel X509 certificate support for authentication FXP site-to-site transfer support One-time password (OTP) support using S/KEY, MD5, RMD160 or SHA1 Site bookmarks with many options configurable per-site Distributed FTP daemon support (implementing the PRET command) Can use Zeroconf for local site discovery Bookmark import plugins from other FTP clients Support for the SFTP protocol A nice traffic graph Ability to limit upload and download speed Priority and skip lists Integrated SFV checksum verifier Direct viewing/editing of remote files Advanced default "on file exists" action configuration Filter displayed files/directories as you type

Homepage: http://www.kftp.org

FileZilla ftp client


FileZilla is a fast and reliable FTP client for Windows with lots of useful features and an intuitive interface. It's now multi-platform. This package contains localization for FileZilla. More than 40 languages are available. Homepage: http://filezilla-project.org/

FTP client how to


This is a basic ftp client guide tutorial. You will learn how to use ftp client from command line terminal and using graphical user interface ftp client program. In command line terminal ftp client guide, you will learn ftp command to connect to the ftp server, download and upload files to the ftp server. It doesn't matter if you use Linux or Windows operating system, ftp is a standard network protocol. The basic ftp commands should be the same.

How to use ftp commands


Most Linux distributions come with ftp client by default. If your Linux doesn't have one, you can always use ftp client from the command line terminal. Just type 'ftp' without any option and enter. You can also use ftp client from Windows command prompt. The procedure is the same as using ftp from Linux command line terminal. Example running ftp client from windows operating system (Click Start --> Run --> cmd):
Microsoft Windows XP [Version 5.1.2600] C) Copyright 1985-2001 Microsoft Corp. C:\Documents and Settings\bill> ftp ftp>

Let's see what commands do we have in ftp program. Type 'help' at the ftp prompt and press 'Enter':
ftp> help Commands may be abbreviated. Commands are: ! delete literal prompt ? debug ls put append dir mdelete pwd ascii disconnect mdir quit bell get mget quote binary glob mkdir recv bye hash mls remotehelp cd help mput rename close lcd open rmdir send status trace type user verbose

We want to establish a connection with the ftp server. The correct ftp command to use is the open command. Type open and press Enter. You need to provide the ftp server's ip address:
ftp> open To 192.168.0.5 Connected to 192.168.0.5. 220 Microsoft FTP Service User (192.168.0.5:(none)): ftpuser 331 Password required for ftpuser. Password: 230 User ftpuser logged in. ftp>

Here are examples using ftp client from Linux command line terminal. To run the ftp client, type 'ftp' at the command prompt and press 'Enter':
bill@slackware:~$ ftp

To open connection with ftp server, use ftp command 'open' and provide ftp server domain name or ip address:
ftp> open (to) ftp.example.com Connected to ftp.example.com. 220---------- Welcome to Pure-FTPd [TLS] ---------220-You are user number 1 of 50 allowed. 220-Local time is now 18:18. Server port: 21. 220-This is a private system - No anonymous login 220-IPv6 connections are also welcome on this server. 220 You will be disconnected after 15 minutes of inactivity. Name (ftp.example.com:bill): bill[@]example.com 331 User bill[@]example.com OK. Password required Password: 230-User bill[@]example.com has group access to: bill 230-OK. Current restricted directory is / 230 0 Kbytes used (0%) - authorized: 2048000 Kb Remote system type is UNIX. Using binary mode to transfer files. ftp>

As we can see from the example above, we use ftp server domain name instead of ftp server's ip address. This is useful since it's easier to remember domain name rather than ip address. Here is another tips. We can also provide ftp server ip address when invoking ftp command. This will skip the ftp 'open' command. See the example below on how to do this:
luzar@slackware:~$ ftp 172.16.153.129 Connected to 172.16.153.129. 220 ProFTPD 1.3.1 Server (Ubuntu FTP server) [172.16.153.129] Name (172.16.153.129:luzar): labu 331 Password required for labu Password: 230-Welcome, archive user labu@172.16.153.1 ! 230230-The local time is: Sat Feb 21 18:26:53 2009 230230-This is an additional FTP server. You only have permission 230-to download files. If you have any unusual problems, 230-please report them via e-mail to root@ubuntu.localdomain. 230230 User labu logged in Remote system type is UNIX. Using binary mode to transfer files. ftp>

Ftp upload how to


Now we are connected to the ftp server. It doesn't matter if we use Linux or windows because once the connection established, all the commands are the same. We use ftp supported commands and you can view them all by issuing help at the ftp prompt. For example, try help mput:
ftp> help mput mput send multiple files

The ftp mput command can be used to send multiple files to the ftp server. That means if we have permission to upload files to ftp server, we can send multiple files using ftp mput command. Let's see

an example on how ftp upload works:


ftp> lcd Local directory now /home/bill ftp> mput perlintro.txt mput perlintro.txt? y 200 PORT command successful 150 Connecting to port 50861 226-24 Kbytes used (0%) - authorized: 2048000 Kb 226-File successfully transferred 226 0.406 seconds (measured here), 59.28 Kbytes per second 24653 bytes sent in 0.134 secs (1.8e+02 Kbytes/sec)

What I did (command in red) above are lcd command to check my 'local directory' (client computer), then I used mput command to upload perlintro.txt file to the ftp server. To confirm the ftp upload, enter y. The ftp command mput also can be used to transfer a single file. However, the correct ftp command to send a single file is the put command.
ftp> help put put ftp> send one file

Ftp download how to


Here is a guide on how to download files from ftp server. Use ftp command mget to download files from ftp server.
ftp> help mget mget get multiple files

Here is an example on how to use ftp mget command to download files from ftp server:
ftp> mget perlintro.txt mget perlintro.txt? y 200 PORT command successful 150-Connecting to port 29807 150 24.1 kbytes to download 226-File successfully transferred 226 0.000 seconds (measured here), 510.94 Mbytes per second 24653 bytes received in 1.07 secs (22 Kbytes/sec)

The ftp command mget normally used to download multiple files from ftp server, but in our example, it is used to download a single file. The right ftp command to download a single file is the get command. You probably noticed, why did I mention this? Because some ftp server did not accept get command, so you can use mget if you happened to encounter one. To exit from ftp server, type bye and press enter.

Graphical user interface (GUI) ftp client


If you are a Linux desktop user and prefer using graphical user interface ftp client program from kde or gnome, here are step by step screenshot examples on how to use gftp ftp client to download and upload files:

Click Remote and choose Open location

Enter domain name or ip address of the ftp server:

Enter username or user account to connect to the ftp server:

Enter password for user account to connect to the ftp server:

If your username valid and your password is correct, you should be successfully login into the ftp server. In gftp, click on the file or directory in the local directory and click upload arrow icon to transfer file to the ftp server. If you want to download file or directory, click on the file or directory in the ftp server, and click download arrow. See screenshot image below for example:

All gui ftp client program works almost the same. If you are using other gui ftp client, and there is no download/upload arrow icon, maybe you can right-click on the file or folder you are going to transfer and see if there are download/upload options available. If not, the transfer menu should be available in your ftp client so that you can upload and download files to the server. That's all you need to know about Linux ftp client. If you are looking for ftp server setup tutorial, you can find it in Linux network - Install and configure vsftpd in Slackware Linux for Slackware ftp server and Linux network - Install and configure proftpd in Ubuntu Server for Ubuntu ftp server. Good luck! Install and using Lynx web browser in Ubuntu In Ubuntu, you can also surf the Internet or view website in command line terminal. One of the great browsers for command line terminal is Lynx. Check out this tutorial for more information about Lynx in Ubuntu.

INSTALL AND CONFIGURE LINUX SERVERS