Home Blog Page 8

The 10 most useful Linux commands

0

Maybe the command line isn’t your favorite place to hang out, but to be an effective Linux admin, you need to be able to wield a few essential commands. These 10 are guaranteed to simplify your Linux admin life — and he explains why.


I understand that many of you don’t want to use the command line in Linux (or in any operating system, for that matter). But the truth is, to be a good administrator, you have to know the command line. Why? Well, with Windows there are times when the command line is the only thing that can save your skin. With Linux, the command line is vast, reliable, flexible, fast… I could go on and on.

And of the 2,119 possible commands from the /usr/bin directory (in Mandriva Spring 2008) and the 388 possible commands from /usr/sbin/, a few are indispensable. Here are 10 of them that might make your Linux admin life — or your introduction to Linux — a whole lot simpler.

I could make this easy and go with the most used commands (cd, ls, rm, etc — okay, etc isn’t a command, but you get the point). But instead, I am going to go with the most useful commands, and I’ll keep it as distribution-neutral as I can.

#1: top

I figured it was fitting to put the top command at the top. Although top is actually responsible for listing currently running tasks, it is also the first command Linux users turn to when they need to know what is using their memory (or even how much memory a system has). I often leave the top tool running on my desktop so I can keep track of what is going on at all times. Sometimes, I will even open up a terminal (usually aterm), place the window where I want it, and then hide the border of the window. Without a border, the terminal can’t be moved, so I always have quick access to the information I need.

Top is a real-time reporting system, so as a process changes, it will immediately be reflected in the terminal window. Top does have some helpful arguments (such as the -p argument, which will have top monitor only user-specified PIDs), but running default, top will give you all the information you need on running tasks.

#2: ln

To many administrators, links are an invaluable tool that not only make users lives simpler but also drastically reduce disk space usage. If you are unaware of how links can help you, let me pose this simple scenario: You have a number of users who have to access a large directory (filled with large files) on a drive throughout the day. The users are all on the same system, and you don’t want to have to copy the entire directory to each user’s ~/ directory. Instead, just create a link in each user’s ~/ directory to the target. You won’t consume space, and the users will have quick access. Of course when spanning drives, you will have to use symlinks. Another outstanding use for links is linking various directories to the Apache doc root directory. Not only can this save space, it’s often advantageous from a security standpoint.

#3: tar/zip/gzip

Tar, zip, and gzip are archival/compression tools that make your administrator life far easier. I bundle these together because the tools can handle similar tasks yet do so with distinct differences (just not different enough to warrant their own entry in this article). Without these tools, installing from source would be less than easy. Without tar/zip/gzip, creating backups would require more space than you might often have.

One of the least used (but often most handy) features of these tools is the ability to extract single files from an archive. Now zip and gzip handle this more easily than tar. With tar, to extract a single file, you have to know the exact size of the file to be extracted. One area where tar/zip/gzip make administration simple is in creating shells scripts that automate a backup process. All three tools can be used with shell scripts and are, hands down, the best, most reliable backup tools you will find.

#4: nano, vi, emacs

I wasn’t about to place just one text editor here, for fear of stoking the fires of the “vi vs. emacs” war. To top that off, I figured it was best to throw my favorite editor — nano — into the mix. Many people would argue that these aren’t so much commands as they are full-blown applications. But all these tools are used within the command line, so I call them “commands.” Without a good text editor, administering a Linux machine can become problematic.

Imagine having to attempt to edit /etc/fstab or /etc/samba/smb.conf with OpenOffice. Some might say this shouldn’t be a problem, but OpenOffice tends to add hidden end-of-line characters to text files, which can really fubar a configuration file. For the editing of configuration or bash files, the only way to go is with an editor such as nano, vi, or emacs.

#5: grep

Many people overlook this amazingly useful tool. Grep prints lines that match a user-specified pattern. Say, for instance, that you are looking at an httpd.conf file that’s more than 1,000 lines long, and you are searching for the “AccessFileName .htaccess” entry. You could comb through that file only to come across the entry at line 429, or you can issue the command grep -n “AccessFileName .htaccess” /etc/httpd/conf/http.conf. Upon issuing this command you will be returned “439:AccessFileName .htaccess” which tells you the entry you are looking for is on, surprise of all surprises, line 439.

The grep command is also useful for piping other commands to. An example of this is using grep with the ps command (which takes a snapshot of current running processes.) Suppose you want to know the PID of the currently crashed Firefox browser. You could issue ps aux and search through the entire output for the Firefox entry. Or you could issue the command ps aux|grep firefox, at which point you might see something like this:

jlwallen 17475  0.0  0.1   3604  1180 ?        Ss   10:54   0:00 /bin/sh /home/jwallen/firefox/firefoxjlwallen 17478  0.0  0.1   3660  1276 ?        S    10:54   0:00 /bin/sh /home/jlwallen/firefox/run-mozilla.sh /home/jlwallen/firefox/firefox-bin

jlwallen 17484 11.0 10.7 227504 97104 ?        Sl   10:54  11:50 /home/jlwallenfirefox/firefox-bin

jlwallen 17987  0.0  0.0   3112   736 pts/0    R+   12:42   0:00 grep --color firefox

Now you know the PIDs of every Firefox command running.

#6: chmod

Permissions anyone? Linux administration and security would be a tough job without the help of chmod. Imagine not being able to make a shell script executable with chmod u+x filename. Of course it’s not just about making a file executable. Many Web tools require certain permissions before they will even install. To this end, the command chmod -R 666 DIRECTORY/ is one very misused command. Many new users, when faced with permissions issues trying to install an application, will jump immediately to 666 instead of figuring out exactly what permissions a directory or folder should have.

Even though this tool is critical for administration, it should be studied before jumping in blindly. Make sure you understand the ins and outs of chmod before using it at will. Remember w=write, r=read, and x=execute. Also remember UGO or User, Group, and Other. UGO is a simple way to remember which permissions belong to whom. So permission rw- rw- rw- means User, Group, and Other all have read and write permissions. It is always best to keep Other highly restricted in their permissions.

#7: dmesg

Call me old-school if you want, but any time I plug a device into a Linux machine, the first thing I do is run the dmesg command. This command displays the messages from the kernel buffer. So, yeah, this is an important one. There is a lot of information to be garnered from the dmesg command. You can find out system architecture, gpu, network device, kernel boot options used, RAM totals, etc.

A nice trick is to pipe dmesg to tail to watch any message that comes to dmesg. To do this, issue the command dmesg | tail -f and the last few lines of dmesg will remain in your terminal. Every time a new entry arrives it will be at the bottom of the “tail.” Keep this window open when doing heavy duty system administration or debugging a system.

#8: kill/killall

One of the greatest benefits of Linux is its stability. But that stability doesn’t always apply to applications outside the kernel. Some applications can actually lock up. And when they do, you want to be able to get rid of them. The quickest way to get rid of locked up applications is with the kill/killall command. The difference between the two commands is that kill requires the PID (process ID number) and killall requires only the executable name.

Let’s say Firefox has locked up. To kill it with the kill command you would first need to locate the PID using the command ps aux|grep firefox command. Once you got the PID, you would issue kill PID (Where PID is the actual PID number). If you didn’t want to go through finding out the PID, you could issue the command killall firefox (although in some instances it will require killall firefox-bin).Of course, kill/killall do not apply (nor should apply) to daemons like Apache, Samba, etc.

#9: man

How many times have you seen “RTFM”? Many would say that acronym stands for “Read the Fine* Manual” (*This word is open for variation not suitable for publication.) In my opinion, it stands for “Read the Fine Manpage.” Manpages are there for a reason — to help you understand how to use a command. Manpages are generally written with the same format, so once you gain an understanding of the format, you will be able to read (and understand) them all. And don’t underestimate the value of the manpage. Even if you can’t completely grasp the information given, you can always scroll down to find out what each command argument does. And the best part of using manpages is that when someone says “RTFM” you can say I have “RTFMd.”

#10: mount/umount

Without these two commands, using removable media or adding external drives wouldn’t happen. The mount/umount command is used to mount a drive (often labeled like /dev/sda) to a directory in the Linux file structure. Both mount and umount take advantage of the /etc/fstab file, which makes using mount/umount much easier. For instance, if there is an entry in the /etc/fstab file for/dev/sda1 that maps it to /data, that drive can be mounted with the command mount /data. Typically mount/umount must have root privileges (unless fstab has an entry allowing standard users to mount and unmount the device). You can also issue the mount command without arguments and you will see all drives that are currently mounted and where they’re mapped to (as well as the type of file system and the permissions).

Can’t live without ‘em

These 10 Linux commands make Linux administration possible. There are other helpful commands, as well as commands that are used a lot more often than these. But the commands outlined here fall into the necessity category. I don’t know about you, but I don’t go a day without using at least half of them. Do you have a Linux command or two that you can’t live without? If so, let us know.

Originally posted 2016-03-14 04:25:12.

yum command: Update / Install Packages Under Redhat Enterprise / CentOS Linux Version 5.x

How do I use yum command to update and patch my Red hat Enterprise Linux / CentOS Linux version 5.x server via RHN / Internet? Can I use up2date command under RHEL 5?

up2date command was part of RHEL v4.x or older version. You need to use yum command to update and patch the system using RHN or Internet. Use yum command to install critical and non-critical security updates as well as binary packages. Login as the root user to install and update the system.

Task: Register my system with RHN

To register your system with RHN type the following command and just follow on screen instructions (CentOS user skip to next step):
# rhn_register

WARNING! These examples only works with RHEL / CentOS Linux version 5.x or above. For RHEL 4.x and older version use up2date command.

Task: Display list of updated software (security fix)

Type the following command at shell prompt:
# yum list updates

Task: Patch up system by applying all updates

To download and install all updates type the following command:
# yum update

Task: List all installed packages

List all installed packages, enter:
# rpm -qa
# yum list installed

Find out if httpd package installed or not, enter:
# rpm -qa | grep httpd*
# yum list installed httpd

Task: Check for and update specified packages

# yum update {package-name-1}
To check for and update httpd package, enter:
# yum update httpd

Task: Search for packages by name

Search httpd and all matching perl packages, enter:
# yum list {package-name}
# yum list {regex}
# yum list httpd
# yum list perl*

Sample output:

Loading "installonlyn" plugin
Loading "security" plugin
Setting up repositories
Reading repository metadata in from local files
Installed Packages
perl.i386                                4:5.8.8-10.el5_0.2     installed
perl-Archive-Tar.noarch                  1.30-1.fc6             installed
perl-BSD-Resource.i386                   1.28-1.fc6.1           installed
perl-Compress-Zlib.i386                  1.42-1.fc6             installed
perl-DBD-MySQL.i386                      3.0007-1.fc6           installed
perl-DBI.i386                            1.52-1.fc6             installed
perl-Digest-HMAC.noarch                  1.01-15                installed
perl-Digest-SHA1.i386                    2.11-1.2.1             installed
perl-HTML-Parser.i386                    3.55-1.fc6             installed
.....
.......
..
perl-libxml-perl.noarch                  0.08-1.2.1             base
perl-suidperl.i386                       4:5.8.8-10.el5_0.2     updates

Task: Install the specified packages [ RPM(s) ]

Install package called httpd:
# yum install {package-name-1} {package-name-2}
# yum install httpd

Task: Remove / Uninstall the specified packages [ RPM(s) ]

Remove package called httpd, enter:
# yum remove {package-name-1} {package-name-2}
# yum remove httpd

Task: Display the list of available packages

# yum list all

Task: Display list of group software

Type the following command:
# yum grouplist
Output:

Installed Groups:
   Engineering and Scientific
   MySQL Database
   Editors
   System Tools
   Text-based Internet
   Legacy Network Server
   DNS Name Server
   Dialup Networking Support
   FTP Server
   Network Servers
   Legacy Software Development
   Legacy Software Support
   Development Libraries
   Graphics
   Web Server
   Ruby
   Printing Support
   Mail Server
   Server Configuration Tools
   PostgreSQL Database
Available Groups:
   Office/Productivity
   Administration Tools
   Beagle
   Development Tools
   GNOME Software Development
   X Software Development
   Virtualization
   GNOME Desktop Environment
   Authoring and Publishing
   Mono
   Games and Entertainment
   XFCE-4.4
   Tomboy
   Java
   Java Development
   Emacs
   X Window System
   Windows File Server
   KDE Software Development
   KDE (K Desktop Environment)
   Horde
   Sound and Video
   FreeNX and NX
   News Server
   Yum Utilities
   Graphical Internet
Done

Task: Install all the default packages by group

Install all ‘Development Tools’ group packages, enter:
# yum groupinstall "Development Tools"

Task: Update all the default packages by group

Update all ‘Development Tools’ group packages, enter:
# yum groupupdate "Development Tools"

Task: Remove all packages in a group

Remove all ‘Development Tools’ group packages, enter:
# yum groupremove "Development Tools"

Task: Install particular architecture package

If you are using 64 bit RHEL version it is possible to install 32 packages:
# yum install {package-name}.{architecture}
# yum install mysql.i386

Task: Display packages not installed via official RHN subscribed repos

Show all packages not available via subscribed channels or repositories i.e show packages installed via other repos:
# yum list extras
Sample output:

Loading "installonlyn" plugin
Loading "security" plugin
Setting up repositories
Reading repository metadata in from local files
Extra Packages
DenyHosts.noarch                         2.6-python2.4          installed
VMwareTools.i386                         6532-44356             installed
john.i386                                1.7.0.2-3.el5.rf       installed
kernel.i686                              2.6.18-8.1.15.el5      installed
kernel-devel.i686                        2.6.18-8.1.15.el5      installed
lighttpd.i386                            1.4.18-1.el5.rf        installed
lighttpd-fastcgi.i386                    1.4.18-1.el5.rf        installed
psad.i386                                2.1-1                  installed
rssh.i386                                2.3.2-1.2.el5.rf       installed

Task: Display what package provides the file

You can easily find out what RPM package provides the file. For example find out what provides the /etc/passwd file:
# yum whatprovides /etc/passwd
Sample output:

Loading "installonlyn" plugin
Loading "security" plugin
Setting up repositories
Reading repository metadata in from local files
setup.noarch                             2.5.58-1.el5           base
Matched from:
/etc/passwd
setup.noarch                             2.5.58-1.el5           installed
Matched from:
/etc/passwd

You can use same command to list packages that satisfy dependencies:
# yum whatprovides {dependency-1} {dependency-2}
Refer yum command man page for more information:
# man yum

Originally posted 2016-03-13 04:00:06.

DOS-to-UNIX file conversion

Using Perl:
# WARNING! For UNIX only! Do not use with ActivePerl in MSYS shell on Windows!
# (Returns error message and file is deleted.)

perl -pi -e 's/\r\n/\n/g' filename

Using sh or bash:
Works fine even in MSYS shell on Windows.

#tr -d '\r' < original_filename > new_filename

(Note that the “<” and “>” must be typed for this command to work).

The same replacing technique can of course be applied to any string.
The following one-liner changes the ‘cellpadding’ value from 4 to 2 in all files in the current directory where the ‘cellpadding’ value is 4, and the ‘cellspacing’ value is 1:

# WARNING! For UNIX only! Do not use with ActivePerl in MSYS shell on Windows!
# (Returns error message and deletes ALL files in directory!)

perl -pi -e  's/cellpadding=\"4\" cellspacing=\"1\"/cellpadding=\"2\" cellspacing=\"1\"/g' *

Originally posted 2016-03-12 03:36:50.

Get Information About Your BIOS / Server Hardware From a Shell Without Opening Chassis ( BIOS Decoder )

0

biosdecode is a command line utility to parses the BIOS memory and prints information about all structures (or entry points) it knows of. You can find out more information about your hardware such as:
=> IPMI Device
=> Type of memory and speed
=> Chassis Information
=> Temperature Probe
=> Cooling Device
=> Electrical Current Probe
=> Processor and Memory Information
=> Serial numbers
=> BIOS version
=> PCI / PCIe Slots and Speed
=> Much more

biosdecode parses the BIOS memory and prints the following information about all structures :
=> SMBIOS (System Management BIOS)
=> DMI (Desktop Management Interface, a legacy version of SMBIOS)
=> SYSID
=> PNP (Plug and Play)
=> ACPI (Advanced Configuration and Power Interface)
=> BIOS32 (BIOS32 Service Directory)
=> PIR (PCI IRQ Routing)
=> 32OS (BIOS32 Extension, Compaq-specific)
=> VPD (Vital Product Data, IBM-specific)
=> FJKEYINF (Application Panel, Fujitsu-specific)

In this tip you will learn about decoding BIOS data (dumping a computer’s DMI ) and getting all information about computer hardware without rebooting the server.

More about the DMI tables

The DMI table doesn’t only describe what the system is currently made of, it also can report the possible evolutions such as the fastest supported CPU or the maximal amount of memory supported.

dmidecode – Read biosdecode data in a human-readable format

Data provided by biosdecode is not in a human-readable format. You need to use dmidecode command for dumping a computer’s DMI (SMBIOS) table contents on screen. This table contains a description of the system’s hardware components, as well as other useful pieces of information such as serial numbers and BIOS revision. Thanks to this table, you can retrieve this information without having to probe for the actual hardware.

Task: Display information about IPMI Device

# dmidecode --type 38
Output:

# dmidecode 2.7
SMBIOS 2.4 present.
Handle 0x0029, DMI type 38, 18 bytes.
IPMI Device Information
        Interface Type: KCS (Keyboard Control Style)
        Specification Version: 2.0
        I2C Slave Address: 0x10
        NV Storage Device: Not Present
        Base Address: 0x0000000000000CA2 (I/O)
        Register Spacing: Successive Byte Boundaries

Task: Display information about PCI / PCIe Slots

# dmidecode --type 9

# dmidecode 2.7
SMBIOS 2.4 present.
Handle 0x000E, DMI type 9, 13 bytes.
System Slot Information
        Designation: PCIX#1-133MHz
        Type: 64-bit PCI-X
        Current Usage: Available
        Length: Long
        ID: 1
        Characteristics:
                3.3 V is provided
Handle 0x000F, DMI type 9, 13 bytes.
System Slot Information
        Designation: PCIX#2-100MHz
        Type: 64-bit PCI-X
        Current Usage: Available
        Length: Long
        ID: 2
        Characteristics:
                3.3 V is provided
Handle 0x0010, DMI type 9, 13 bytes.
System Slot Information
        Designation: PCIE#3-x8
        Type: Other
        Current Usage: Available
        Length: Other
        Characteristics:
                3.3 V is provided
Handle 0x0011, DMI type 9, 13 bytes.
System Slot Information
        Designation: PCIE#4-x8
        Type: Other
        Current Usage: Available
        Length: Other
        Characteristics:
                3.3 V is provided
Handle 0x0012, DMI type 9, 13 bytes.
System Slot Information
        Designation: PCIE#5-x8
        Type: Other
        Current Usage: Available
        Length: Other
        Characteristics:
                3.3 V is provided

Task: Find out Information about BIOS

# dmidecode --type 0
Output:

# dmidecode 2.7
SMBIOS 2.4 present.
Handle 0x0000, DMI type 0, 24 bytes.
BIOS Information
        Vendor: Phoenix Technologies LTD
        Version: 6.00
        Release Date: 01/26/2007
        Address: 0xE56C0
        Runtime Size: 108864 bytes
        ROM Size: 1024 kB
        Characteristics:
                PCI is supported
                PNP is supported
                BIOS is upgradeable
                BIOS shadowing is allowed
                ESCD support is available
                Boot from CD is supported
                Selectable boot is supported
                EDD is supported
                3.5"/2.88 MB floppy services are supported (int 13h)
                ACPI is supported
                USB legacy is supported
                LS-120 boot is supported
                ATAPI Zip drive boot is supported
                BIOS boot specification is supported
                Targeted content distribution is supported

Understanding BIOS keywords

dmidecode --type {KEYWORD / Number }

You need to pass dmidecode following keywords:

  • bios
  • system
  • baseboard
  • chassis
  • processor
  • memory
  • cache
  • connector
  • slot

All DMI types you need to use with dmidecode –type {Number}:

# TypeShort Description
0BIOS
1System
2Base Board
3Chassis
4Processor
5Memory Controller
6Memory Module
7Cache
8Port Connector
9System Slots
10On Board Devices
11OEM Strings
12System Configuration Options
13BIOS Language
14Group Associations
15System Event Log
16Physical Memory Array
17Memory Device
1832-bit Memory Error
19Memory Array Mapped Address
20Memory Device Mapped Address
21Built-in Pointing Device
22Portable Battery
23System Reset
24Hardware Security
25System Power Controls
26Voltage Probe
27Cooling Device
28Temperature Probe
29Electrical Current Probe
30Out-of-band Remote Access
31Boot Integrity Services
32System Boot
3364-bit Memory Error
34Management Device
35Management Device Component
36Management Device Threshold Data
37Memory Channel
38IPMI Device
39Power Supply

Display Power supply information, enter:
# dmidecode --type 39
Display CPU information, enter:
# dmidecode --type processor
Read man page for more information:
$ man dmidecode

Originally posted 2016-03-11 03:16:51.

Linux: Restart Nginx WebServer

0

How do I restart nginx web server under Linux?

To restart nginx web server use any one of the following command as a root user:
# /etc/init.d/nginx restart
However, recommed way is as follows which should work with any Linux distribution :
# nginx -s reload
OR
# /usr/local/nginx/sbin/nginx -s reload

Originally posted 2016-03-10 02:57:42.

Linux / Unix: Find Out Maximum RAM Supported By The Server BIOS / Motherboard

0

How do I find out the maximum RAM supported by the Dell / HP / IBM / Oracle / Sun / Intel / AMD server under Linux / Unix / HP-UX / FreeBSD / Solaris operating systems without rebooting the server or opening server case (cabinet)?

Most modern server supports 16GB, 32GB, 64GB or more RAM and has 4 or more DIMM slots. To find out what is the maximum system can support type the following command as root user:
# dmidecode -t 16
Sample outputs:

# dmidecode 2.11
SMBIOS 2.5 present.
Handle 0x0016, DMI type 16, 15 bytes
Physical Memory Array
	Location: System Board Or Motherboard
	Use: System Memory
	Error Correction Type: None
	Maximum Capacity: 64 GB
	Error Information Handle: Not Provided
	Number Of Devices: 8

 

(Fig.01: This server supports maximum 64 GB and has 8 DIMM slots)

However, my old good home server can support max 4GB ram:
# dmidecode -t 16
Sample outputs:

 

# dmidecode 2.9
SMBIOS 2.6 present.
Handle 0x0008, DMI type 16, 15 bytes
Physical Memory Array
	Location: System Board Or Motherboard
	Use: System Memory
	Error Correction Type: None
	Maximum Capacity: 4 GB
	Error Information Handle: Not Provided
	Number Of Devices: 2

 

(Fig.02: My home server supports maximum 4 GB RAM and has total 2 DIMM slots)

You can find out currently installed memory information (DIMM and its slots) by typing the following command:
# dmidecode -t 17
Sample outputs:

 

# dmidecode 2.9
SMBIOS 2.6 present.
Handle 0x000A, DMI type 17, 28 bytes
Memory Device
	Array Handle: 0x0008
	Error Information Handle: Not Provided
	Total Width: 64 bits
	Data Width: 64 bits
	Size: 2048 MB
	Form Factor: DIMM
	Set: None
	Locator: DIMM0
	Bank Locator: BANK0
	Type: DDR2
	Type Detail: Synchronous
	Speed: 667 MHz (1.5 ns)
	Manufacturer: Manufacturer00
	Serial Number: SerNum00
	Asset Tag: AssetTagNum0
	Part Number: ModulePartNumber00
Handle 0x000C, DMI type 17, 28 bytes
Memory Device
	Array Handle: 0x0008
	Error Information Handle: Not Provided
	Total Width: Unknown
	Data Width: Unknown
	Size: No Module Installed
	Form Factor: DIMM
	Set: None
	Locator: DIMM1
	Bank Locator: BANK1
	Type: Unknown
	Type Detail: Unknown
	Speed: Unknown
	Manufacturer: Manufacturer01
	Serial Number: SerNum01
	Asset Tag: AssetTagNum1
	Part Number: ModulePartNumber01

 

(Fig.03: Find out installed RAM information)

Another output from one of my personal server:
# dmidecode -t 17
Sample outputs:

 

# dmidecode 2.11
SMBIOS 2.5 present.
Handle 0x0013, DMI type 17, 27 bytes
Memory Device
	Array Handle: 0x0012
	Error Information Handle: No Error
	Total Width: 40968 bits
	Data Width: 41032 bits
	Size: 512 MB
	Form Factor: DIMM
	Set: 1
	Locator: J6G1
	Bank Locator: DIMM 0
	Type: DDR2
	Type Detail: Synchronous
	Speed: 667 MHz
	Manufacturer: Kingston
	Serial Number: 80CC2564
	Asset Tag: 00000903
	Part Number: 393930353332302D3030322E4130314C4600
Handle 0x0014, DMI type 17, 27 bytes
Memory Device
	Array Handle: 0x0012
	Error Information Handle: No Error
	Total Width: 41480 bits
	Data Width: 41544 bits
	Size: 512 MB
	Form Factor: DIMM
	Set: 1
	Locator: J6G2
	Bank Locator: DIMM 1
	Type: DDR2
	Type Detail: Synchronous
	Speed: 667 MHz
	Manufacturer: Kingston
	Serial Number: 80CC1E64
	Asset Tag: 00000903
	Part Number: 393930353332302D3030322E4130314C4600
Handle 0x0015, DMI type 17, 27 bytes
Memory Device
	Array Handle: 0x0012
	Error Information Handle: No Error
	Total Width: 41992 bits
	Data Width: 42056 bits
	Size: 512 MB
	Form Factor: DIMM
	Set: 1
	Locator: J6H1
	Bank Locator: DIMM 2
	Type: DDR2
	Type Detail: Synchronous
	Speed: 667 MHz
	Manufacturer: Kingston
	Serial Number: BCCCFD8D
	Asset Tag: 00000833
	Part Number: 393930353332302D3030322E4130314C4600
Handle 0x0016, DMI type 17, 27 bytes
Memory Device
	Array Handle: 0x0012
	Error Information Handle: No Error
	Total Width: 42504 bits
	Data Width: 42568 bits
	Size: 512 MB
	Form Factor: DIMM
	Set: 1
	Locator: J6H2
	Bank Locator: DIMM 3
	Type: DDR2
	Type Detail: Synchronous
	Speed: 667 MHz
	Manufacturer: Kingston
	Serial Number: BCCCDF8D
	Asset Tag: 00000833
	Part Number: 393930353332302D3030322E4130314C4600

 

(Fig.04: This server has 512MBx4 Kingston DIMM installed)
 

memconf Perl Script

You can download memconf here and run it as follows:

 
$ cd /tmp
$ wget http://www.4schmidts.com/unix/memconf.gz
$ gunzip memconf.gz
# perl memconf -v

Sample outputs:

memconf:  V2.22 30-Jan-2012 http://www.4schmidts.com/unix.html
hostname: dbmsyq05.nixcraft.net.in
Supermicro X7DBR-3 (Dual-Core Intel(R) Xeon(TM) 2000MHz)
Memory Error Correction: None
Maximum Memory: 65536MB (64GB)
DIMM1A Bank1: 2048MB 667MHz Synchronous DDR2 DIMM, 0000
DIMM2A Bank2: 2048MB 667MHz Synchronous DDR2 DIMM, 0000
DIMM3A Bank3: 2048MB 667MHz Synchronous DDR2 DIMM, 0000
DIMM4A Bank4: 2048MB 667MHz Synchronous DDR2 DIMM, 0000
empty memory sockets: DIMM1B Bank1, DIMM2B Bank2, DIMM3B Bank3, DIMM4B Bank4
total memory = 8192MB (8GB)
WARNING: ECC memory detected, but ECC is not enabled in the BIOS.

 

(Fig.05: Runs on Linux / Solaris / HP-UX / FreeBSD to displays memory modules installed in server)
 

Online Info

Another option is to visit your server or computer manufacturer website and find out the same info.

Originally posted 2016-03-09 02:43:16.

Apache Address already in use: make_sock: could not bind to port 80 or 443 error

0

Q. How do I fix an error, while restarting Apache ~ Address already in use: make_sock: could not bind to port 80?

A. If you are running SELinux disable temporary for port 80.

Apache Address already in use: make_sock: could not bind to port 80 error and solution

First make sure port 80/443 is not used by any other service or application with netstat command:

# netstat -tulpn| grep :80

If port 80 is bind to httpd, kill all process:
# killall -9 httpd

Now start the httpd:
# /etc/init.d/httpd start

Also make sure you are root while starting the httpd.

Originally posted 2016-03-08 02:39:24.

Install Imagemagik on Cpanel and Cloudlinux

Imagemagik installation on a cpanel server is quite easy. Imagemagik is an addon for your cPanel server that allows for image manipulation. ImageMagick® is a software suite to create, edit, compose, or convert bitmap images. It can read and write images in a variety of formats (over 100) including DPX, EXR, GIF, JPEG, JPEG-2000, PDF, PNG, Postscript, SVG, and TIFF. Use ImageMagick to resize, flip, mirror, rotate, distort, shear and transform images, adjust image colors, apply various special effects, or draw text, lines, polygons, ellipses and Bézier curves.

–> Installation via commandline
–> Installation via WHM
–> Installation on CloudLinux installed server

1: Installation via commandline

Step I : How to check whether the Imagemagick installed or not on the server?

You may first check if it is already installed on the server. You can use the following way to figure it out from the command line.

/scripts/checkimagemagick
/usr/bin/convert --version

Step II : Installation

/scripts/installimagemagick

This will take a couple of minutes to complete. After installation you can check the version by executing the command, /usr/bin/convert –version
Sample output:

[email protected] [~]# /usr/bin/convert --version
Version: ImageMagick 6.5.4-7 2014-02-10 Q16 OpenMP http://www.imagemagick.org
Copyright: Copyright (C) 1999-2009 ImageMagick Studio LLC

How to uninstall imagemagik from command line?

Execute the following command to remove imagemagik from your server.

/scripts/cleanimagemagick

2: Installation steps via WHM control panel

Step I : Login to WHM control panel.
Step II : Do follow these steps,

Go to WHM -> Software -> Module Installers -> PHP Pecl (manage). On the box below “Install a PHP Pecl” enter “imagick” and click “Install Now” button.

Step III : Restart apache.

imagick

Removal steps via WHM:

Step I : Login to WHM control panel.
Step II : Do follow these steps,

Imagick: WHM -> Software -> Module Installers -> PHP Pecl (manage). Click on Uninstall button for Imagick

Step III : Restart apache.

3: Installation on CloudLinux installed server

In a CloudLinux installed server there is an additional step to enable packages for users on that server. Installing packages on the server wont reflect in these cases. You will want to install ImageMagick inside CageFS as follows to make those binaries available inside CageFS and  to users:

To see the list of RPMs currently installed under CageFS:

cagefsctl --list-rpm

To add a new RPM:

cagefsctl --addrpm ImageMagick

To pick up the changes:

cagefsctl --force-update

Originally posted 2016-03-07 19:12:21.

How to delete a file

0

How do I delete a file under Linux  operating system?

To remove a file or directory in Linux use the rm command.

rm command syntax

rm (short for remove) is a Unix / Linux command which is used to delete files from a filesystem. Usually, on most filesystems, deleting a file requires write permission on the parent directory (and execute permission, in order to enter the directory in the first place). The syntax is as follows:

rm -f -r {file-name}

Where,

  • -f: Forcefully remove file
  • -r: Remove the contents of directories recursively

Remove or Delete a File

To remove a file called abc.txt type the following command:
$ rm abc.txt

To remove all files & subdirectories from a directory (MS-DOS deltree like command), enter:
$ rm -rf mydir

To remove empty directory use rmdir and not rm command:
$ rmdir mydirectory

Read a List of All Files To Delete From a Text File

The rm command is often used in conjunction with xargs to supply a list of files to delete. Create a file called file.txt:
$ cat file.txt
List of to delete:

file1
/tmp/file2.txt
~/data.txt

Now delete all file listed in file.txt, enter:
$ xargs rm < file.txt

Never run rm -rf / as an administrator or normal Linux user

WARNING!  These examples will delete all files on your computer if executed.
$ rm -rf /
$ rm -rf *

rm -rf (variously, rm -rf /, rm -rf *, and others) is frequently used in jokes and anecdotes about Linux disasters. The rm -rf / variant of the command, if run by an administrator, would cause the contents of every writable mounted filesystem on the computer to be deleted. Do not try these commands.

Originally posted 2016-03-07 02:15:51.

Fixing time drift in the servers (syncing with time servers)

0

Sometimes the clock in the system may shows some drift ( lagging or leading) in time.  We can fix this by adjusting the tick rate in the server.

1. Compare the system time with that of any timeserver. You can use any of  the following command for this.

rdate -p rdate.cpanel.net ;date

OR

rdate -p rdate.darkorb.net ;date

Here rdate prints the time in remote timeserver( rdate.cpanel.net or rdate.darkorb.net) and date will print the current system time.

2. To synchronize the time with remote server issue the following commands.

rdate -s rdate.cpanel.net ;date

OR

rdate -s rdate.darkorb.net ;date

3. Now set the hardware clock in the server. Execute the following command for this.

hwclock –systohc

4. Now execute the same command (step1) after one or two minutes and see the drift in time. Check whether it increases or decreases.

5. Find the current tick rate using the following command. By default this will be 10000. You can interpret this as  10000 ticks causes one second in the server.

tickadj
tick = 10000

6. If the the time drift increases positively you need to reduce the tick rate. You can adjust the tick rate using the following command.

tickadj 9995
tick = 9995

7. Continue the above steps until the issue resolved.

===============

Aliter

To fix the time drift issue, you can put a cronjob to sync the time with the time server.

Add the following entry in cronjob ( type crontab -e to edit cron jobs)

*/5 * * * * rdate -s rdate.cpanel.net;/sbin/hwclock -w >/dev/null 2>&1

OR

*/5 * * * * rdate -s rdate rdate.darkorb.net;/sbin/hwclock -w >/dev/null 2>&1

Originally posted 2016-03-06 01:50:41.