Search for:
Fast – Test Your Internet Download Speed in Linux

Fast &-8211; Test Your Internet Download Speed in Linux &-8211; this Article or News was published on this date:2019-05-30 13:53:31 kindly share it with friends if you find it helpful

If your internet download speed seems poor, you most likely go at Speedtest.net and check, yes?. As this is the easiest way to test the speeds that we’re getting from our internet service provider, and it’s been a most liked choice for years.

But Netflix’s own speed testing service – Fast.com, a free, fast and simple tool that allows users to check their current Internet download and upload speed with latency in its excellent clean, ad-free interface. Since it uses Netflix’s own servers to test, so you can easily track if your ISP is throttling your speed.

Just head over to Fast.com to do a speed test of your current internet download speed.

Test Internet Download SpeedTest Internet Download Speed

Test Internet Download Speed

If you want to check the current internet speed of your Linux server from the command-line, you can use a utility called fast – a minimal zero-dependency script, written in Go language for testing your internet download speed from the terminal, which is powered by Fast.com – Netflix and runs on Linux, Windows and Mac.

This speed testing tool is very simple and has no options whatsoever. Simply, download binary file for your architecture (fast_linux_amd64 for 64bit systems) in your home directory, set execute permission and run it directly from the terminal to test your server Internet speed.

$ wget https://github.com/ddo/fast/releases/download/v0.0.4/fast_linux_amd64 -O fast
$ chmod +x fast
$ ./fast
Test Internet Download SpeedLinux Server Internet Speed Test

Linux Server Internet Speed Test

If you want, you can install it under /usr/local/bin directory on any Linux distribution by using the following commands.

$ wget https://github.com/ddo/fast/releases/download/v0.0.4/fast_linux_amd64 
$ sudo install fast_linux_amd64 /usr/local/bin/fast
$ fast
Test Internet Download SpeedInstall Fast.com Tool in Linux

Install Fast.com Tool in Linux

You can also install Fast on any Linux distribution using snap (requires snapd to be installed on the system).

$ snap install fast

That’s all! In this article, we have explained how to check current Internet download and upload speed of Linux systems using Fast.com speed testing service.

MySQL Backup and Restore Commands for Database Administration

MySQL Backup and Restore Commands for Database Administration &-8211; this Article or News was published on this date:2019-05-28 19:57:20 kindly share it with friends if you find it helpful

This article shows you several practical examples on how to perform various backup operations of MySQL databases using mysqldump command and also we will see how to restore them with the help of mysql and mysqlimport command in Linux.

mysqldump is a command-line client program, it is used to dump local or remote MySQL database or collection of databases for backup into a single flat file.

How to backup mysql databaseHow to backup mysql database

How to Backup and Restore MySQL Database

We assume that you already have MySQL installed on Linux system with administrative privileges and we assume that you already have a small amount of knowledge on MySQL. If you don’t have MySQL installed or don’t have any exposure to MySQL then read our articles below.

  1. Install MySQL Server on RHEL/CentOS 6-5, Fedora 17-12
  2. 20 MySQL Commands for Database Administration

How to Backup MySQL Database?

To take a backup of MySQL database or databases, the database must exist in the database server and you must have access to it. The format of the command would be.

- mysqldump -u [username] –p[password] [database_name] > [dump_file.sql]

The parameters of the said command as follows.

  1. [username] : A valid MySQL username.
  2. [password] : A valid MySQL password for the user.
  3. [database_name] : A valid Database name you want to take backup.
  4. [dump_file.sql] : The name of backup dump file you want to generate.

How to Backup a Single MySQL Database?

To take a backup of single database, use the command as follows. The command will dump database [rsyslog] structure with data on to a single dump file called rsyslog.sql.

- mysqldump -u root -psfnews rsyslog > rsyslog.sql

How to Backup Multiple MySQL Databases?

If you want to take backup of multiple databases, run the following command. The following example command takes a backup of databases [rsyslog, syslog] structure and data in to a single file called rsyslog_syslog.sql.

- mysqldump -u root -psfnews --databases rsyslog syslog > rsyslog_syslog.sql

How to Backup All MySQL Databases?

If you want to take backup of all databases, then use the following command with option –all-database. The following command takes the backup of all databases with their structure and data into a file called all-databases.sql.

- mysqldump -u root -psfnews --all-databases > all-databases.sql

How to Backup MySQL Database Structure Only?

If you only want the backup of database structure without data, then use the option –no-data in the command. The below command exports database [rsyslog] Structure into a file rsyslog_structure.sql.

- mysqldump -u root -psfnews -–no-data rsyslog > rsyslog_structure.sql

How to Backup MySQL Database Data Only?

To backup database Data only without structure, then use the option –no-create-info with the command. This command takes the database [rsyslog] Data  into a file rsyslog_data.sql.

- mysqldump -u root -psfnews --no-create-db --no-create-info rsyslog > rsyslog_data.sql

How to Backup Single Table of Database?

With the below command you can take backup of single table or certain tables of your database. For example, the following command only take backup of wp_posts table from the database wordpress.

- mysqldump -u root -psfnews wordpress wp_posts > wordpress_posts.sql

How to Backup Multiple Tables of Database?

If you want to take backup of multiple or certain tables from the database, then separate each table with space.

- mysqldump -u root -psfnews wordpress wp_posts wp_comments > wordpress_posts_comments.sql

How to Backup Remote MySQL Database

The below command takes the backup of remote server [172.16.25.126] database [gallery] into a local server.

- mysqldump -h 172.16.25.126 -u root -psfnews gallery > gallery.sql

How to Restore MySQL Database?

In the above tutorial we have seen the how to take the backup of databases, tables, structures and data only, now we will see how to restore them using following format.

- - mysql -u [username] –p[password] [database_name]  [dump_file.sql]

How to Restore Single MySQL Database

To restore a database, you must create an empty database on the target machine and restore the database using msyql command. For example the following command will restore the rsyslog.sql file to the rsyslog database.

- mysql -u root -psfnews rsyslog  rsyslog.sql

If you want to restore a database that already exist on targeted machine, then you will need to use the mysqlimport command.

- mysqlimport -u root -psfnews rsyslog  rsyslog.sql

In the same way you can also restore database tables, structures and data. If you liked this article, then do share it with your friends.

8 Practical Examples of Linux “Touch” Command

8 Practical Examples of Linux &-8220;Touch&-8221; Command &-8211; this Article or News was published on this date:2019-05-28 19:56:12 kindly share it with friends if you find it helpful

In Linux every single file is associated with timestamps, and every file stores the information of last access time, last modification time and last change time. So, whenever we create new file, access or modify an existing file, the timestamps of that file automatically updated.

Linux Touch CommandLinux Touch Command

Linux Touch Command Examples

In this article we will cover some useful practical examples of Linux touch command. The touch command is a standard program for Unix/Linux operating systems, that is used to create, change and modify timestamps of a file. Before heading up for touch command examples, please check out the following options.

Touch Command Options

  1. -a, change the access time only
  2. -c, if the file does not exist, do not create it
  3. -d, update the access and modification times
  4. -m, change the modification time only
  5. -r, use the access and modification times of file
  6. -t, creates a file using a specified time

1. How to Create an Empty File

The following touch command creates an empty (zero byte) new file called sheena.

- touch sheena

2. How to Create Multiple Files

By using touch command, you can also create more than one single file. For example the following command will create 3 files named, sheena, meena and leena.

- touch sheena meena leena

3. How to Change File Access and Modification Time

To change or update the last access and modification times of a file called leena, use the -a option as follows. The following command sets the current time and date on a file. If the leena file does not exist, it will create the new empty file with the name.

- touch -a leena

The most popular Linux commands such as find command and ls command uses timestamps for listing and finding files.

4. How to Avoid Creating New File

Using -c option with touch command avoids creating new files. For example the following command will not create a file called leena if it does not exists.

- touch -c leena

5. How to Change File Modification Time

If you like to change the only modification time of a file called leena, then use the -m option with touch command. Please note it will only updates the last modification times (not the access times) of the file.

- touch -m leena

6. Explicitly Set the Access and Modification times

You can explicitly set the time using -c and -t option with touch command. The format would be as follows.

- touch -c -t YYDDHHMM leena

For example the following command sets the access and modification date and time to a file leena as 17:30 (17:30 p.m.) December 10 of the current year (2012).

- touch -c -t 12101730 leena

Next verify the access and modification time of file leena, with ls -l command.

- ls -l

total 2
-rw-r--r--.  1 root    root   0 Dec 10 17:30 leena

7. How to Use the time stamp of another File

The following touch command with -r option, will update the time-stamp of file meena with the time-stamp of leena file. So, both the file holds the same time stamp.

- touch -r leena meena

8. Create a File using a specified time

If you would like to create a file with specified time other than the current time, then the format should be.

- touch -t YYMMDDHHMM.SS sfnews

For example the below command touch command with -t option will gives the sfnews file a time stamp of 18:30:55 p.m. on December 10, 2012.

- touch -t 201212101830.55 sfnews

We’ve almost covered all the options available in the touch command for more options use “man touch“. If we’ve still missed any options and you would like to include in this list, please update us via comment box.

30 Useful Linux Commands for System Administrators

30 Useful Linux Commands for System Administrators &-8211; this Article or News was published on this date:2019-05-28 19:55:44 kindly share it with friends if you find it helpful

In this article we are going to review some of the useful and frequently used Linux or Unix commands for Linux System Administrators that are used in their daily life. This is not a complete but it’s a compact list of commands to refer when needed. Let us start one by one how we can use those commands with examples.

Linux System Administration CommandsLinux System Administration Commands

30 Useful Linux System Administration Commands

1. Uptime Command

In Linux uptime command shows since how long your system is running and the number of users are currently logged in and also displays load average for 1,5 and 15 minutes intervals.

- uptime

08:16:26 up 22 min,  1 user,  load average: 0.00, 0.03, 0.22

Check Uptime Version

Uptime command don’t have other options other than uptime and version. It gives information only in hours:mins if it less than 1 day.

[[email protected] ~]$ uptime -V
procps version 3.2.8

2. W Command

It will displays users currently logged in and their process along-with shows load averages. also shows the login name, tty name, remote host, login time, idle time, JCPU, PCPU, command and processes.

- w

08:27:44 up 34 min,  1 user,  load average: 0.00, 0.00, 0.08
USER     TTY      FROM              [email protected]   IDLE   JCPU   PCPU WHAT
sfnews  pts/0    192.168.50.1     07:59    0.00s  0.29s  0.09s w

Available options

  1. -h : displays no header entries.
  2. -s : without JCPU and PCPU.
  3. -f : Removes from field.
  4. -V : (upper letter) – Shows versions.

3. Users Command

Users command displays currently logged in users. This command don’t have other parameters other than help and version.

- users

sfnews

4. Who Command

who command simply return user name, date, time and host information. who command is similar to w command. Unlike w command who doesn’t print what users are doing. Lets illustrate and see the different between who and w commands.

- who

sfnews  pts/0        2012-09-18 07:59 (192.168.50.1)
- w

08:43:58 up 50 min,  1 user,  load average: 0.64, 0.18, 0.06
USER     TTY      FROM              [email protected]   IDLE   JCPU   PCPU WHAT
sfnews  pts/0    192.168.50.1     07:59    0.00s  0.43s  0.10s w

Who command Options

  1. -b : Displays last system reboot date and time.
  2. -r : Shows current runlet.
  3. -a, –all : Displays all information in cumulatively.

5. Whoami Command

whoami command print the name of current user. You can also use “who am i” command to display the current user. If you are logged in as a root using sudo command “whoami” command return root as current user. Use “who am i” command if you want to know the exact user logged in.

- whoami

sfnews

6. ls Command

ls command display list of files in human readable format.

- ls -l

total 114
dr-xr-xr-x.   2 root root  4096 Sep 18 08:46 bin
dr-xr-xr-x.   5 root root  1024 Sep  8 15:49 boot

Sort file as per last modified time.

- ls -ltr

total 40
-rw-r--r--. 1 root root  6546 Sep 17 18:42 install.log.syslog
-rw-r--r--. 1 root root 22435 Sep 17 18:45 install.log
-rw-------. 1 root root  1003 Sep 17 18:45 anaconda-ks.cfg

For more examples of ls command, please check out our article on 15 Basic ‘ls’ Command Examples in Linux.

7. Crontab Command

List schedule jobs for current user with crontab command and -l option.

- crontab -l

00 10 * * * /bin/ls >/ls.txt

Edit your crontab with -e option. In the below example will open schedule jobs in VI editor. Make a necessary changes and quit pressing :wq keys which saves the setting automatically.

- crontab -e

For more examples of Linux Cron Command, please read our earlier article on 11 Cron Scheduling Task Examples in Linux.

8. Less Command

less command allows quickly view file. You can page up and down. Press ‘q‘ to quit from less window.

- less install.log

Installing setup-2.8.14-10.el6.noarch
warning: setup-2.8.14-10.el6.noarch: Header V3 RSA/SHA256 Signature, key ID c105b9de: NOKEY
Installing filesystem-2.4.30-2.1.el6.i686
Installing ca-certificates-2010.63-3.el6.noarch
Installing xml-common-0.6.3-32.el6.noarch
Installing tzdata-2010l-1.el6.noarch
Installing iso-codes-3.16-2.el6.noarch

9. More Command

more command allows quickly view file and shows details in percentage. You can page up and down. Press ‘q‘ to quit out from more window.

- more install.log

Installing setup-2.8.14-10.el6.noarch
warning: setup-2.8.14-10.el6.noarch: Header V3 RSA/SHA256 Signature, key ID c105b9de: NOKEY
Installing filesystem-2.4.30-2.1.el6.i686
Installing ca-certificates-2010.63-3.el6.noarch
Installing xml-common-0.6.3-32.el6.noarch
Installing tzdata-2010l-1.el6.noarch
Installing iso-codes-3.16-2.el6.noarch
--More--(10%)

10. CP Command

Copy file from source to destination preserving same mode.

- cp -p fileA fileB

You will be prompted before overwrite to file.

- cp -i fileA fileB

11. MV Command

Rename fileA to fileB. -i options prompt before overwrite. Ask for confirmation if exist already.

- mv -i fileA fileB

12. Cat Command

cat command used to view multiple file at the same time.

- cat fileA fileB

You combine more and less command with cat command to view file contain if that doesn’t fit in single screen / page.

- cat install.log | less

- cat install.log | more

For more examples of Linux cat command read our article on 13 Basic Cat Command Examples in Linux.

13. Cd command (change directory)

with cd command (change directory) it will goes to fileA directory.

- cd /fileA

14. pwd command (print working directory)

pwd command return with present working directory.

- pwd

/root

15. Sort command

Sorting lines of text files in ascending order. with -r options will sort in descending order.

-sort fileA.txt

-sort -r fileA.txt

16. VI Command

Vi is a most popular text editor available most of the UNIX-like OS. Below examples open file in read only with -R option. Press ‘:q‘ to quit from vi window.

- vi -R /etc/shadows

17. SSH Command (Secure Shell)

SSH command is used to login into remote host. For example the below ssh command will connect to remote host (192.168.50.2) using user as narad.

- ssh [email protected]

To check the version of ssh use option -V (uppercase) shows version of ssh.

- ssh -V

OpenSSH_5.3p1, OpenSSL 1.0.0-fips 29 Mar 2010

18. Ftp or sftp Command

ftp or sftp command is used to connect to remote ftp host. ftp is (file transfer protocol) and sftp is (secure file transfer protocol). For example the below commands will connect to ftp host (192.168.50.2).

- ftp 192.168.50.2

- sftp 192.168.50.2

Putting multiple files in remote host with mput similarly we can do mget to download multiple files from remote host.

- ftp > mput *.txt

- ftp > mget *.txt

19. Service Command

Service command call script located at /etc/init.d/ directory and execute the script. There are two ways to start the any service. For example we start the service called httpd with service command.

- service httpd start
OR
- /etc/init.d/httpd start

20. Free command

Free command shows free, total and swap memory information in bytes.

- free
             total       used       free     shared    buffers     cached
Mem:       1030800     735944     294856          0      51648     547696
-/+ buffers/cache:     136600     894200
Swap:      2064376          0    2064376

Free with -t options shows total memory used and available to use in bytes.

- free -t
             total       used       free     shared    buffers     cached
Mem:       1030800     736096     294704          0      51720     547704
-/+ buffers/cache:     136672     894128
Swap:      2064376          0    2064376
Total:     3095176     736096    2359080

21. Top Command

top command displays processor activity of your system and also displays tasks managed by kernel in real-time. It’ll show processor and memory are being used. Use top command with ‘u‘ option this will display specific User process details as shown below. Press ‘O‘ (uppercase letter) to sort as per desired by you. Press ‘q‘ to quit from top screen.

- top -u sfnews

top - 11:13:11 up  3:19,  2 users,  load average: 0.00, 0.00, 0.00
Tasks: 116 total,   1 running, 115 sleeping,   0 stopped,   0 zombie
Cpu(s):  0.0%us,  0.3%sy,  0.0%ni, 99.7%id,  0.0%wa,  0.0%hi,  0.0%si,  0.0%st
Mem:   1030800k total,   736188k used,   294612k free,    51760k buffers
Swap:  2064376k total,        0k used,  2064376k free,   547704k cached

PID USER      PR  NI  VIRT  RES  SHR S %CPU %MEM    TIME+  COMMAND
1889 sfnews   20   0 11468 1648  920 S  0.0  0.2   0:00.59 sshd
1890 sfnews   20   0  5124 1668 1416 S  0.0  0.2   0:00.44 bash
6698 sfnews   20   0 11600 1668  924 S  0.0  0.2   0:01.19 sshd
6699 sfnews   20   0  5124 1596 1352 S  0.0  0.2   0:00.11 bash

For more about top command we’ve already compiled a list of 12 TOP Command Examples in Linux.

22. Tar Command

tar command is used to compress files and folders in Linux. For example the below command will create a archive for /home directory with file name as archive-name.tar.

- tar -cvf archive-name.tar /home

To extract tar archive file use the option as follows.

- tar -xvf archive-name.tar

To understand more about tar command we’ve created a complete how-to guide on tar command at 18 Tar Command Examples in Linux.

23. Grep Command

grep search for a given string in a file. Only sfnews user displays from /etc/passwd file. we can use -i option for ignoring case sensitive.

- grep sfnews /etc/passwd

sfnews:x:500:500::/home/sfnews:/bin/bash

24. Find Command

Find command used to search files, strings and directories. The below example of find command search sfnews word in ‘/‘ partition and return the output.

- find / -name sfnews

/var/spool/mail/sfnews
/home/sfnews
/root/home/sfnews

For complete guide on Linux find command examples fount at 35 Practical Examples of Linux Find Command.

25. lsof Command

lsof mean List of all open files. Below lsof command list of all opened files by user sfnews.

- lsof -u sfnews

COMMAND  PID    USER   FD   TYPE     DEVICE SIZE/OFF   NODE NAME
sshd    1889 sfnews  cwd    DIR      253,0     4096      2 /
sshd    1889 sfnews  txt    REG      253,0   532336 298069 /usr/sbin/sshd
sshd    1889 sfnews  DEL    REG      253,0          412940 /lib/libcom_err.so.2.1
sshd    1889 sfnews  DEL    REG      253,0          393156 /lib/ld-2.12.so
sshd    1889 sfnews  DEL    REG      253,0          298643 /usr/lib/libcrypto.so.1.0.0
sshd    1889 sfnews  DEL    REG      253,0          393173 /lib/libnsl-2.12.so
sshd    1889 sfnews  DEL    REG      253,0          412937 /lib/libkrb5support.so.0.1
sshd    1889 sfnews  DEL    REG      253,0          412961 /lib/libplc4.so

For more lsof command examples visit 10 lsof Command Examples in Linux.

26. last command

With last command we can watch user’s activity in the system. This command can execute normal user also. It will display complete user’s info like terminal, time, date, system reboot or boot and kernel version. Useful command to troubleshoot.

- last

sfnews  pts/1        192.168.50.1     Tue Sep 18 08:50   still logged in
sfnews  pts/0        192.168.50.1     Tue Sep 18 07:59   still logged in
reboot   system boot  2.6.32-279.el6.i Tue Sep 18 07:54 - 11:38  (03:43)
root     pts/1        192.168.50.1     Sun Sep 16 10:40 - down   (03:53)
root     pts/0        :0.0             Sun Sep 16 10:36 - 13:09  (02:32)
root     tty1         :0               Sun Sep 16 10:07 - down   (04:26)
reboot   system boot  2.6.32-279.el6.i Sun Sep 16 09:57 - 14:33  (04:35)
narad    pts/2        192.168.50.1     Thu Sep 13 08:07 - down   (01:15)

You can use last with username to know for specific user’s activity as shown below.

- last sfnews

sfnews  pts/1        192.168.50.1     Tue Sep 18 08:50   still logged in
sfnews  pts/0        192.168.50.1     Tue Sep 18 07:59   still logged in
sfnews  pts/1        192.168.50.1     Thu Sep 13 08:07 - down   (01:15)
sfnews  pts/4        192.168.50.1     Wed Sep 12 10:12 - 12:29  (02:17)

27. ps command

ps command displays about processes running in the system. Below example show init process only.

- ps -ef | grep init

root         1     0  0 07:53 ?        00:00:04 /sbin/init
root      7508  6825  0 11:48 pts/1    00:00:00 grep init

28. kill command

Use kill command to terminate process. First find process id with ps command as shown below and kill process with kill -9 command.

- ps -ef | grep init
root         1     0  0 07:53 ?        00:00:04 /sbin/init
root      7508  6825  0 11:48 pts/1    00:00:00 grep init

- kill- 9 7508

29. rm command

rm command used to remove or delete a file without prompting for confirmation.

- rm filename

Using -i option to get confirmation before removing it. Using options ‘-r‘ and ‘-f‘ will remove the file forcefully without confirmation.

- rm -i test.txt

rm: remove regular file `test.txt'?

30. mkdir command example.

mkdir command is used to create directories under Linux.

- mkdir directoryname

This is a handy day to day useable basic commands in Linux / Unix-like operating system. Kindly share through our comment box if we missed out.

15 Useful “ifconfig” Commands to Configure Network Interface in Linux

15 Useful &-8220;ifconfig&-8221; Commands to Configure Network Interface in Linux &-8211; this Article or News was published on this date:2019-05-28 19:55:21 kindly share it with friends if you find it helpful

ifconfig in short “interface configuration” utility for system/network administration in Unix/Linux operating systems to configure, manage and query network interface parameters via command line interface or in a system configuration scripts.

The “ifconfig” command is used for displaying current network configuration information, setting up an ip address, netmask or broadcast address to an network interface, creating an alias for network interface, setting up hardware address and enable or disable network interfaces.

Ifconfig Command ExamplesIfconfig Command Examples

15 Useful ifconfig Commands

This article covers “15 Useful “ifconfig” Commands” with their practical examples, that might be very helpful to you in managing and configuring network interfaces in Linux systems.

Update : The networking command ifconfig is deprecated and replaced by ip command (Learn 10 Examples of IP Command) in most Linux distributions.

Don’t Miss: ifconfig vs ip: What’s Difference Between Them

1. View All Network Setting

The “ifconfig” command with no arguments will display all the active interfaces details. The ifconfig command also used to check the assigned IP address of an server.

[[email protected] ~]- ifconfig

eth0      Link encap:Ethernet  HWaddr 00:0B:CD:1C:18:5A
          inet addr:172.16.25.126  Bcast:172.16.25.63  Mask:255.255.255.224
          inet6 addr: fe80::20b:cdff:fe1c:185a/64 Scope:Link
          UP BROADCAST RUNNING MULTICAST  MTU:1500  Metric:1
          RX packets:2341604 errors:0 dropped:0 overruns:0 frame:0
          TX packets:2217673 errors:0 dropped:0 overruns:0 carrier:0
          collisions:0 txqueuelen:1000
          RX bytes:293460932 (279.8 MiB)  TX bytes:1042006549 (993.7 MiB)
          Interrupt:185 Memory:f7fe0000-f7ff0000

lo        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:5019066 errors:0 dropped:0 overruns:0 frame:0
          TX packets:5019066 errors:0 dropped:0 overruns:0 carrier:0
          collisions:0 txqueuelen:0
          RX bytes:2174522634 (2.0 GiB)  TX bytes:2174522634 (2.0 GiB)

tun0      Link encap:UNSPEC  HWaddr 00-00-00-00-00-00-00-00-00-00-00-00-00-00-00-00
          inet addr:10.1.1.1  P-t-P:10.1.1.2  Mask:255.255.255.255
          UP POINTOPOINT RUNNING NOARP 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:100
          RX bytes:0 (0.0 b)  TX bytes:0 (0.0 b)

2. Display Information of All Network Interfaces

The following ifconfig command with -a argument will display information of all active or inactive network interfaces on server. It displays the results for eth0, lo, sit0 and tun0.

[[email protected] ~]- ifconfig -a

eth0      Link encap:Ethernet  HWaddr 00:0B:CD:1C:18:5A
          inet addr:172.16.25.126  Bcast:172.16.25.63  Mask:255.255.255.224
          inet6 addr: fe80::20b:cdff:fe1c:185a/64 Scope:Link
          UP BROADCAST RUNNING MULTICAST  MTU:1500  Metric:1
          RX packets:2344927 errors:0 dropped:0 overruns:0 frame:0
          TX packets:2220777 errors:0 dropped:0 overruns:0 carrier:0
          collisions:0 txqueuelen:1000
          RX bytes:293839516 (280.2 MiB)  TX bytes:1043722206 (995.3 MiB)
          Interrupt:185 Memory:f7fe0000-f7ff0000

lo        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:5022927 errors:0 dropped:0 overruns:0 frame:0
          TX packets:5022927 errors:0 dropped:0 overruns:0 carrier:0
          collisions:0 txqueuelen:0
          RX bytes:2175739488 (2.0 GiB)  TX bytes:2175739488 (2.0 GiB)

sit0      Link encap:IPv6-in-IPv4
          NOARP  MTU:1480  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)

tun0      Link encap:UNSPEC  HWaddr 00-00-00-00-00-00-00-00-00-00-00-00-00-00-00-00
          inet addr:10.1.1.1  P-t-P:10.1.1.2  Mask:255.255.255.255
          UP POINTOPOINT RUNNING NOARP 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:100
          RX bytes:0 (0.0 b)  TX bytes:0 (0.0 b)

3. View Network Settings of Specific Interface

Using interface name (eth0) as an argument with “ifconfig” command will display details of specific network interface.

[[email protected] ~]- ifconfig eth0

eth0      Link encap:Ethernet  HWaddr 00:0B:CD:1C:18:5A
          inet addr:172.16.25.126  Bcast:172.16.25.63  Mask:255.255.255.224
          inet6 addr: fe80::20b:cdff:fe1c:185a/64 Scope:Link
          UP BROADCAST RUNNING MULTICAST  MTU:1500  Metric:1
          RX packets:2345583 errors:0 dropped:0 overruns:0 frame:0
          TX packets:2221421 errors:0 dropped:0 overruns:0 carrier:0
          collisions:0 txqueuelen:1000
          RX bytes:293912265 (280.2 MiB)  TX bytes:1044100408 (995.7 MiB)
          Interrupt:185 Memory:f7fe0000-f7ff0000

4. How to Enable an Network Interface

The “up” or “ifup” flag with interface name (eth0) activates an network interface, if it is not in active state and allowing to send and receive information. For example, “ifconfig eth0 up” or “ifup eth0” will activate the eth0 interface.

[[email protected] ~]- ifconfig eth0 up
OR
[[email protected] ~]- ifup eth0

5. How to Disable an Network Interface

The “down” or “ifdown” flag with interface name (eth0) deactivates the specified network interface. For example, “ifconfig eth0 down” or “ifdown eth0” command deactivates the eth0 interface, if it is in active state.

[[email protected] ~]- ifconfig eth0 down
OR
[[email protected] ~]- ifdown eth0

6. How to Assign a IP Address to Network Interface

To assign an IP address to an specific interface, use the following command with an interface name (eth0) and ip address that you want to set. For example, “ifconfig eth0 172.16.25.125” will set the IP address to interface eth0.

[[email protected] ~]- ifconfig eth0 172.16.25.125

7. How to Assign a Netmask to Network Interface

Using the “ifconfig” command with “netmask” argument and interface name as (eth0) allows you to define an netmask to an given interface. For example, “ifconfig eth0 netmask 255.255.255.224” will set the network mask to an given interface eth0.

[[email protected] ~]- ifconfig eth0 netmask 255.255.255.224

8. How to Assign a Broadcast to Network Interface

Using the “broadcast” argument with an interface name will set the broadcast address for the given interface. For example, “ifconfig eth0 broadcast 172.16.25.63” command sets the broadcast address to an interface eth0.

[[email protected] ~]- ifconfig eth0 broadcast 172.16.25.63

9. How to Assign a IP, Netmask and Broadcast to Network Interface

To assign an IP address, Netmask address and Broadcast address all at once using “ifconfig” command with all arguments as given below.

[[email protected] ~]- ifconfig eth0 172.16.25.125 netmask 255.255.255.224 broadcast 172.16.25.63

10. How to Change MTU for an Network Interface

The “mtu” argument set the maximum transmission unit to an interface. The MTU allows you to set the limit size of packets that are transmitted on an interface. The MTU able to handle maximum number of octets to an interface in one single transaction. For example, “ifconfig eth0 mtu 1000” will set the maximum transmission unit to given set (i.e. 1000). Not all network interfaces supports MTU settings.

[[email protected] ~]- ifconfig eth0 mtu 1000

11. How to Enable Promiscuous Mode

What happens in normal mode, when a packet received by a network card, it verifies that the packet belongs to itself. If not, it drops the packet normally, but in the promiscuous mode is used to accept all the packets that flows through the network card.

Most of the today’s network tools uses the promiscuous mode to capture and analyze the packets that flows through the network interface. To set the promiscuous mode, use the following command.

[[email protected] ~]- ifconfig eth0 promisc

12. How to Disable Promiscuous Mode

To disable promiscuous mode, use the “-promisc” switch that drops back the network interface in normal mode.

[[email protected] ~]- ifconfig eth0 -promisc

13. How to Add New Alias to Network Interface

The ifconfig utility allows you to configure additional network interfaces using alias feature. To add alias network interface of eth0, use the following command. Please note that alias network address in same sub-net mask. For example, if your eth0 network ip address is 172.16.25.125, then alias ip address must be 172.16.25.127.

[[email protected] ~]- ifconfig eth0:0 172.16.25.127

Next, verify the newly created alias network interface address, by using “ifconfig eth0:0” command.

[[email protected] ~]- ifconfig eth0:0

eth0:0    Link encap:Ethernet  HWaddr 00:01:6C:99:14:68
          inet addr:172.16.25.123  Bcast:172.16.25.63  Mask:255.255.255.240
          UP BROADCAST RUNNING MULTICAST  MTU:1500  Metric:1
          Interrupt:17

14. How to Remove Alias to Network Interface

If you no longer required an alias network interface or you incorrectly configured it, you can remove it by using the following command.

[[email protected] ~]- ifconfig eth0:0 down

15. How to Change the MAC address of Network Interface

To change the MAC (Media Access Control) address of an eth0 network interface, use the following command with argument “hw ether“. For example, see below.

[[email protected] ~]- ifconfig eth0 hw ether AA:BB:CC:DD:EE:FF

These are the most useful commands for configuring network interfaces in Linux, for more information and usage of ifconfig command use the manpages like “man ifconfig” at the terminal. Check out some other networking utilities below.

Other Networking Utilities

  1. Tcmpdump — is an command-line packet capture and analyzer tool for monitoring network traffic.
  2. Netstat — is an open source command line network monitoring tool that monitors incoming and outgoing network packets traffic.
  3. Wireshark — is an open source network protocol analyzer that is used to troubleshoot network related issues.
  4. Munin — is an web based network and system monitoring application that is used to display results in graphs using rrdtool.
  5. Cacti — is an complete web based monitoring and graphing application for network monitoring.

To get more information and options for any of the above tools, see the manapages by entering “man toolname” at the command prompt. For example, to get the information for “netstat” tool, use the command as “man netstat“.