DISCLAIMER : Please note that blog owner takes no responsibility of any kind for any type of data loss or damage by trying any of the command/method mentioned in this blog. You may use the commands/method/scripts on your own responsibility.If you find something useful, a comment would be appreciated to let other viewers also know that the solution/method work(ed) for you.
Single command to find out RAM(memory) size in Linux
You can use the command cat /proc/meminfo to get the memory details in the linux operating system.
But this gives much more information of memory.
If you need just the memory size , use the below command to get that.
cat /proc/meminfo | awk 'match($1,"MemTotal") == 1 {print $2}'
This gives the memory size in kilobytes(kb).
But I don't know if the format of /proc/meminfo varies among distribution.
But this gives much more information of memory.
If you need just the memory size , use the below command to get that.
cat /proc/meminfo | awk 'match($1,"MemTotal") == 1 {print $2}'
This gives the memory size in kilobytes(kb).
But I don't know if the format of /proc/meminfo varies among distribution.
Display Number of Processors on Linux
If you’ve just upgraded your Linux box, or you are wondering how many processors a remote server has, there’s a quick command you can use to display the number of processors.
On Linux, /proc/cpuinfo contains all of the processor information for all current processors in your computer. This will include the speed, the amount of on-chip cache, processor type, and how many cores.
Here’s the command:
cat /proc/cpuinfo | grep processor | wc -lThe command just looks in the /proc/cpuinfo file, pulls out the number of lines containing the word “processor” and passes them into wc (word count), which returns a count of the CPUs in the system.
uudecode Command
The uudecode utility reads a file or standard input if no file is specified, that includes data created by the uuencode utility. The uudecode utility scans the input file, searching for data compatible with the format specified in uuencode and attempts to create or overwrite the file described by the data. The pathname, file access permission bits and contents for the file to be produced are all contained in that data. The mode bits of the created file will be set from the file access permission bits contained in the data; that is, other attributes of the mode, including the file mode creation mask, will not affect the file being produced.
If the pathname of the file to be produced exists, and the user does not have write permission on that file, uudecode will terminate with an error. If the pathname of the file to be produced exists, and the user has write permission on that file, the existing file will be overwritten.
If the input data was produced by uuencode on a system with a different number of bits per byte than on the target system, the results of uudecode are unspecified.
Purpose
Decodes a binary file that was used for transmission using electronic mail.
Syntax
uudecode [ -o OutputFile ] [ InFile ]
Description
The uudecode command reads an encoded file, strips off leading and trailing lines added by mailers, and recreates the original file with the specified mode and name. Decoding a file causes the result to be automatically saved to a file. The file name is identical to the remote file argument originally supplied to the uuencode command unless an output file name is specified with the -o flag.
Flags
-o OutputFile Specifies the output file name that will be used instead of any pathname contained in the input data. You can direct the output of uudecode to standard output by specifying /dev/stdout as the OutputFile.
Parameters
InFile | Specifies the name of the file to decode. |
Example
To decode the file /tmp/con on a local system that was encoded with the follwing command:
uuencode /usr/lib/boot/unix pigmy.goat > /tmp/con
enter: uudecode /tmp/con
The file pigmy.goat will be identical to the originally encoded file /usr/lib/boot/unix.
uuencode Command
The uuencode utility writes an encoded version of the named input file, or standard input if no file is specified, to standard output. The output is encoded using the algorithm described in the STDOUT section and includes the file access permission bits (in chmod octal or symbolic notation) of the input file and the decode_pathname, for re-creation of the file on another system that conforms to this specification
Purpose
Encodes a binary file for transmission using electronic mail.
Syntax
uuencode [ -m ] [ SourceFile ] OutputFile
Description
The uuencode command converts a binary file to ASCII data. This is useful before using BNU (or uucp) mail to send the file to a remote system. The uudecode command converts ASCII data created by the uuencode command back into its original binary form.
The uuencode command takes the named SourceFile (default standard input) and produces an encoded version on the standard output. The encoding uses only printable ASCII characters, and includes the mode of the file and the OutputFile filename used for recreation of the binary image on the remote system.
Use the uudecode command to decode the file.
Flags
-m Encode the output using the MIME Base64 algorithm. If -m is not specified, the old uuencode algorithm will be used.
Parameters
Examples
To encode the file unix on the local system and mail it to the user jsmith on another system called mysys, enter: uuencode unix unix | mail jsmith@mysys
To encode the file /usr/lib/boot/unix on your local system with the name pigmy.goat in the file /tmp/con , enter: uuencode /usr/lib/boot/unix pigmy.goat > /tmp/con
SUDO in UNIX
Sudo is a standard way to give users some administrative rights without giving out the root
password. Sudo is very useful in a multi user environment with a mix of server and
workstations. Simply call the command with sudo:
# sudo /etc/init.d/dhcpd restart # Run the rc script as root
# sudo -u sysadmin whoami # Run cmd as an other user
Configuration :
Sudo is configured in /etc/sudoers and must only be edited with visudo. The basic syntax is
(the lists are comma separated):
hosts list of hosts (or ALL)
runas list of users (or ALL) that the command rule can be run as. It is enclosed in ( )!
commands list of commands (or ALL) that will be run as root or as (runas)
Additionally those keywords can be defined as alias, they are called User_Alias, Host_Alias,
Runas_Alias and Cmnd_Alias. This is useful for larger setups.
Here a sudoers example:
# cat /etc/sudoers
# Host aliases are subnets or hostnames.
Host_Alias DMZ = 212.118.81.40/28
Host_Alias DESKTOP = work1, work2
# User aliases are a list of users which can have the same rights
User_Alias ADMINS = colin, luca, admin
User_Alias DEVEL = joe, jack, julia
Runas_Alias DBA = oracle,pgsql
# Command aliases define the full path of a list of commands
Cmnd_Alias SYSTEM = /sbin/reboot,/usr/bin/kill,/sbin/halt,/sbin/shutdown,/etc/init.d/
Cmnd_Alias PW = /usr/bin/passwd [A-z]*, !/usr/bin/passwd root # Not root pwd!
Cmnd_Alias DEBUG = /usr/sbin/tcpdump,/usr/bin/wireshark,/usr/bin/nmap
# The actual rules
root,ADMINS ALL = (ALL) NOPASSWD: ALL # ADMINS can do anything w/o a password.
DEVEL DESKTOP = (ALL) NOPASSWD: ALL # Developers have full right on desktops
DEVEL DMZ = (ALL) NOPASSWD: DEBUG # Developers can debug the DMZ servers.
# User sysadmin can mess around in the DMZ servers with some commands.
sysadmin DMZ = (ALL) NOPASSWD: SYSTEM,PW,DEBUG
sysadmin ALL,!DMZ = (ALL) NOPASSWD: ALL # Can do anything outside the DMZ.
%dba ALL = (DBA) ALL # Group dba can run as database user.
# anyone can mount/unmount a cd-rom on the desktop machines
ALL DESKTOP = NOPASSWD: /sbin/mount /cdrom,/sbin/umount /cdrom
password. Sudo is very useful in a multi user environment with a mix of server and
workstations. Simply call the command with sudo:
# sudo /etc/init.d/dhcpd restart # Run the rc script as root
# sudo -u sysadmin whoami # Run cmd as an other user
Configuration :
Sudo is configured in /etc/sudoers and must only be edited with visudo. The basic syntax is
(the lists are comma separated):
user hosts = (runas) commands # In /etc/sudoers
users one or more users or %group (like %wheel) to gain the rightshosts list of hosts (or ALL)
runas list of users (or ALL) that the command rule can be run as. It is enclosed in ( )!
commands list of commands (or ALL) that will be run as root or as (runas)
Additionally those keywords can be defined as alias, they are called User_Alias, Host_Alias,
Runas_Alias and Cmnd_Alias. This is useful for larger setups.
Here a sudoers example:
# cat /etc/sudoers
# Host aliases are subnets or hostnames.
Host_Alias DMZ = 212.118.81.40/28
Host_Alias DESKTOP = work1, work2
# User aliases are a list of users which can have the same rights
User_Alias ADMINS = colin, luca, admin
User_Alias DEVEL = joe, jack, julia
Runas_Alias DBA = oracle,pgsql
# Command aliases define the full path of a list of commands
Cmnd_Alias SYSTEM = /sbin/reboot,/usr/bin/kill,/sbin/halt,/sbin/shutdown,/etc/init.d/
Cmnd_Alias PW = /usr/bin/passwd [A-z]*, !/usr/bin/passwd root # Not root pwd!
Cmnd_Alias DEBUG = /usr/sbin/tcpdump,/usr/bin/wireshark,/usr/bin/nmap
# The actual rules
root,ADMINS ALL = (ALL) NOPASSWD: ALL # ADMINS can do anything w/o a password.
DEVEL DESKTOP = (ALL) NOPASSWD: ALL # Developers have full right on desktops
DEVEL DMZ = (ALL) NOPASSWD: DEBUG # Developers can debug the DMZ servers.
# User sysadmin can mess around in the DMZ servers with some commands.
sysadmin DMZ = (ALL) NOPASSWD: SYSTEM,PW,DEBUG
sysadmin ALL,!DMZ = (ALL) NOPASSWD: ALL # Can do anything outside the DMZ.
%dba ALL = (DBA) ALL # Group dba can run as database user.
# anyone can mount/unmount a cd-rom on the desktop machines
ALL DESKTOP = NOPASSWD: /sbin/mount /cdrom,/sbin/umount /cdrom
Difference between /etc/hosts and /etc/resolv.conf
/etc/resolv.conf specifies the nameservers for resolver lookups, where it will actual use the DNS protocol for resolving the hostnames.
Typically the /etc/hosts file is used for administrative purposes such as backend and internal functions, which is substantially more isolated in scope, as only the local server will reference it it.
/etc/nsswitch.conf specifies the lookup order with the hosts entry.
If this does not answer your question, please clarify further.
Look at the following manpages:
/etc/resolv.conf specifies nameservers in order of search preference.
/etc/hosts overrides all nameservers by mapping urls/shortnames to IPs.
Typically the /etc/hosts file is used for administrative purposes such as backend and internal functions, which is substantially more isolated in scope, as only the local server will reference it it.
/etc/nsswitch.conf specifies the lookup order with the hosts entry.
If this does not answer your question, please clarify further.
Look at the following manpages:
/etc/resolv.conf specifies nameservers in order of search preference.
/etc/hosts overrides all nameservers by mapping urls/shortnames to IPs.
Extracting snap.pax.Z file - AIX
For basic dump analysis, this article is mostly interested in a dump image. Here, we cover how to extract the appropriate files from the snap package and then explain a methodical approach to examine the dump, and find the fundamental reason for a system crash. The dump file and the UNIX® file are in the dump subdirectory of the snap package.
Though we are primarily focused on the dump image, it is important to note that snap can provide you with useful information when used with appropriate options. Additional information is found in the General and Kernel subsections of the article.
General
This general directory includes information about the system runtime environment, for example:
Kernel
The kernel subdirectory contains useful kernel information (Process and memory data).
Extracting the snap package
The pax command is used to extract files from the snap package.
To view the contents of a snap package, type:
# zcat snap.pax.Z | pax -v
To extract the entire contents of a package, type:
# zcat snap.pax.Z | pax -r
To extract just the dump, general, and kernel subdirectories, type:
#uncompress snap.pax.Z
#zcat snap.pax.Z | pax -r ./dump ./general ./kernel
Though we are primarily focused on the dump image, it is important to note that snap can provide you with useful information when used with appropriate options. Additional information is found in the General and Kernel subsections of the article.
General
This general directory includes information about the system runtime environment, for example:
- Copy of ODM data.
- All environment variables (e.g., PATH and TZ).
- Date and time the data was collected.
- Amount of real memory on the system (bootinfo -r).
- Listing of all defined paging spaces.
- Listing of all installed filesets and their levels.
- Listing of all installed APARs.
- Device attributes (lsattr -El).
- System VPD information (lscfg -pv).
- Status of last dump (sysdumpdev -L).
Kernel
The kernel subdirectory contains useful kernel information (Process and memory data).
- Date and time the data was collected
- Vmstat output
- VMM tunable information (vmo -L).
- Scheduling tunable information (schedo -L).
- I/O related tunable iformation (ioo -L).
- Environment variables.
- SRC information (lssrc -a).
- Process information (ps -ef and ps -leaf).
- Checksum of device drivers and methods.
Extracting the snap package
The pax command is used to extract files from the snap package.
To view the contents of a snap package, type:
# zcat snap.pax.Z | pax -v
To extract the entire contents of a package, type:
# zcat snap.pax.Z | pax -r
To extract just the dump, general, and kernel subdirectories, type:
#uncompress snap.pax.Z
#zcat snap.pax.Z | pax -r ./dump ./general ./kernel
Open Source with AIX
AIX has a large range of Open Source tools, and applications already
ported and packaged ready for you to install. This makes it far easier
and quick to get Open Source tools and applications working and useful
on AIX. All the big popular Open Source stuff is available. My
favourites that are in the first URL below are:
Well, your list might be different but there are hundreds of them available. You can, of course, download the original source code and compile it yourself but this means you will need the compilers (most use the GNC compilers), some programing skills and time to read up on the options and build process. then you need to perform some testing to prove it is all working.
Hint: I always compile with the latest GNU compilers to avoid problems.
- Apache - web server the one that runs the web
- emacs - editor and so much more
- ethereal - network monitoring by packets, protocol, contents
- Ganglia - cluster performance monitoring and graphing
- GNC GCC - compiler collection particularly C and C++
- gimp - image manipulation
- Gnome - desktop
- KDE - desktop
- gzip - file compression utility
- MySQL - the database
- PHP - scripting, good for web servers
- rdist - file distribution
- Samba - Windows filesystem and printing and much more
- rxvt - colour xterm
- squid - proxy server
- vim - improved vi editor for colourised syntax highlighing
- VNC - Virtual Network Computing X windows on any machine (even Windows!!)
- wget - checking and copying websites
Well, your list might be different but there are hundreds of them available. You can, of course, download the original source code and compile it yourself but this means you will need the compilers (most use the GNC compilers), some programing skills and time to read up on the options and build process. then you need to perform some testing to prove it is all working.
Hint: I always compile with the latest GNU compilers to avoid problems.