Archive for the 'faq' Category Page 3 of 3



FAQ: How to retreive hardware manufacturer name, serial numbers, etc. in Linux command line

ibm serial numberQuestion: How can I get information about hardware manufacturer, model name, serial number, BIOS information using Linux command line (CLI)?

Answer: You are welcome to use dmidecode which helps to get information about your system’s hardware as described in your system BIOS. That information typically includes system manufacturer, model name, serial number, BIOS version, asset tag as well as a lot of other details depending on the manufacturer.

Beware that DMI data have proven to be too unreliable to be blindly trusted. Dmidecode does not scan your hardware, it only reports what the BIOS told it to. Dmidecode was first written by Alan Cox and is now being further developed and maintained by Jean Delvare. It is released under the General Public License (GPL).

This tool can be easily downloaded from here (source code) or can be installed as binary package included into repositories of many distributions like Debian, Ubuntu, Gentoo. FreeBSD version is also available. Actualy it is reported that dmidecode works well on the following systems:

  • Linux i386
  • Linux x86_64
  • Linux ia64
  • FreeBSD i386
  • FreeBSD x86_64
  • NetBSD i386
  • OpenBSD i386
  • BeOS i386
  • Cygwin i386
  • Solaris x86 (CVS version)

In Ubuntu (my favourite distro) just execute the following: sudo aptitude install dmidecode (sample output is here).

FAQ: static routes after restart/reboot in Fedora/RedHat/CentOS

route 66Static routing is the term used to refer to the manual method used to set up routing. An administrator enters routes into the router using configuration commands. This method has the advantage of being predictable, and simple to set up. It is easy to manage in small networks but does not scale well.

Question: How can I save static routes I set up in my Fedora/RedHat/CentOS Linux after I reboot server?

Answer: In Fedora Linux (or RedHat, CentOS) you can set up static routes for certain network interface (for example eth1) by editing file /etc/sysconfig/network-scripts/route-eth1.

For example, you have to save static route added by the following command:

route add -net 192.168.0.0 netmask 255.255.255.0 gw 192.168.100.1 dev eth1

To do it, just add the following line to /etc/sysconfig/network-scripts/route-eth1:

ADDRESS0=192.168.0.0
NETMASK0=255.255.255.0
GATE
WAY0=192.168.100.1

FAQ: How to install Flash Player for Firefox in Ubuntu Linux?

flash player iconQ: I can’t see flash content at various sites like youtube.com when I visit them through newly installed Firefox browser.. How can I install Flash Player in Firefox under Ubuntu?

A: It is easy in most situations, so close all Firefox instances and run the following in terminal to install flash player for Firefox and other Mozilla based browsers in Ubuntu Linux:

sudo apt-get install flashplugin-nonfree

When finished, just open Firefox and visit some flash content reach site…

FAQ: Change forgotten or lost MySQL root password

Question: I forgot root password for MySQL DBE. How to reset or recover it? PLEASE HELP!

Answer: Below is simple algorithm to reset MySQL root password in Linux, FreeBSD, OpenBSD and other Unix like operating systems:

1. Stop MySQL server process by one of the following commands:
# /etc/init.d/mysqld stop
# killall -9 mysqld
# kill `cat /mysql-data-directory/host_name.pid`
# mysqladmin shutdown

To check if mysqld is killed run "ps ax | grep mysqld" that should show no mysqld instances.

2. Start MySQL server without password protection:
$ mysqld --skip-grant-tables --user=root &
or
$ mysqld --skip-grant-tables &

3. Login to MySQL console by "mysql -u root" and set up new password with the following mysql commands:
mysql> UPDATE mysql.user SET Password=PASSWORD('newpassword') WHERE User='root';
mysql> FLUSH PRIVILEGES;

4. Now you should be able to connect MySQL with new password.

P.S. There is alternative 2 and 3 steps:

2. Create text file /tmp/init.mysql with the following contents:
SET PASSWORD FOR 'root'@'localhost' = PASSWORD('newpassword');

3. Start MySQL with command:
# mysqld_safe --init-file=~/mysql-init &

Hope it helps!!!

FAQ: How to find out CPU load in Linux?

It’s rather trivial task to get information about how much of CPU time is consumed by Linux operating system, its components or various software it runs, but thankfully there are numerous utilities making it possible to get it. Some of them are included into certain Linux distribution, other aren’t but most of tools listed below can be used to find out CPU utilization statistics:

1. top

top is very old and important core utility coming with almost any Linux and Unix operating systems. It shows real-time system resources utilization (CPU, RAM, swap file etc.) to administrators via console, here is the part of it’s output:

top - 16:05:38 up 3 days,  6:08,  2 users,  load average: 0.54, 0.54, 0.61
Tasks: 100 total,   2 running,  98 sleeping,   0 stopped,   0 zombie
Cpu(s):  5.3%us,  1.0%sy,  0.0%ni, 93.7%id,  0.0%wa,  0.0%hi,  0.0%si,  0.0%st
Mem:    515984k total,   497928k used,    18056k free,    13988k buffers
Swap:  1502068k total,    92956k used,  1409112k free,   129096k cached

As this tool provides a lot of useful information, it makes sense to read its manual page: type man top.

2. atsar

sar, atsar are other old tools providing system activity reports including CPU load we need. Here is an example of sar’s usage:

viper@viper-desktop:~$ sar -u 2 5
Linux  viper-desktop  2.6.20-17-generic  #2 SMP Mon Jun 9 22:08:13 UTC 2008  i686  07/04/2008
16:13:58  cpu %usr %nice   %sys %irq %softirq    %wait %idle             _cpu_
16:14:00  all    3     0      0    0        0        1    97
16:14:02  all    0     0      0    0        0        0    99
16:14:04  all    0     0      0    0        0        0   100
16:14:06  all   23     0      0    0        0        0    76
16:14:08  all    0     0      0    0        0        0   100

As you might see CPU utilization was almost 0% for two seconds after the command was executed. BTW, here is the description of the options sar was started with:

-u showed statistics about CPU utilization (average and per cpu) with 5 intervals of 2 seconds.

3. ps

ps is one the most used core utilities every Linux or Unix administrator uses as this utility with short name shows processes run in the system. If you need to get information about how much CPU or RAM resources are consumed by certain process, just run this:

viper@viper-desktop:~$ ps u 23988
USER PID %CPU %MEM VSZ RSS TTY STAT START TIME COMMAND
viper 23988 0.0 0.6 5760 3280 pts/0 Ss 15:54 0:00 bash

where 23988 is PID of the process (can be get from the output of ps ax).

Of course it makes sense to read manuals of above mentioned commands ps, top, sar, atsar, iostat. Good luck!




Pages: Prev 1 2 3
Friendly Sites:Who is behind Linux Screw?
GeekyBits³ | Bash Cures Cancer | OMG! Ubuntu!
My SysAd Blog | Web Upd8
ZEPY | Linux config Wiki | Planet Sysadmin
a non-geek's linux notes | Linux Today
Linux HOWTOs, Tutorials & Projects with Adam Palmer | LinuxAlt.Com
My name is Artem N. (artiomix AT gmail DOT com) and I'm Linux/Unix, Cisco systems engineer. The main idea of Linux Screw is to share relevant knowledge, skills and observations over The Web. Here you can find a lot of information related to different Linux distributions, FreeBSD, IOS as well as a other Open Source around staff. Read more ››