Monday 1 December 2014

Linux file system structure

Linux file system structure

  





/ – The Root Directory

Everything on Linux system is located under the / or root directory. The meaning of / or root and root user are often confusing to new Linux users. In Linux, the root directory “/” (The tree of the file system starts at the trunk or slash, indicated by a forward slash /) is a separator between a file and a directory contains all underlying directories and files, yet root user is a super user or administrator user with has administrative privileges on the system vs Linux privileged users who only have limited privileges to protect system security.


/bin – Essential command binaries

The /bin directory is a place contains most commonly essential executable terminal binaries programs or file required during booting, repairing like cat, ls, mount, rm, du, df, tar, rpm, wc, etc.


/boot – Boot loader files

All of the required files to boot the system contains in /boot directory, including GRUB boot loader’s files, Linux kernels, the Linux initial RAM disk (initrd),


/dev – Device Files

All of the hardware devices on the machine like cdrom, cpu, hard drives, etc will be stored as special device files that represent all the devices in /dev directory. Device files are created during your Linux system installation.


/etc – Configuration Files

Contain host-specific files and directories, e.g. information about system and application configuration files like startup, shutdown, start, stop script for every individual program. In another word /etc data is very similar to Control panel in Microsoft Windows.


/home – Home Directory

Home directory of the users. Every time you create a new user, a new directory with user’s name is created in /home directory for users to store their own files within their own home’s directory. Most common automatic directories created within /home ‘s user are Desktop, Downloads, Documents, Music, Movie, etc. Most programs configuration file for a specific user will be saved in it’s users /home directory like web browser settings, web browser bookmarks, desktop wallpaper, themes, and passwords.


/lib – Essential Libraries

Similar to Windows ‘dll’ files, all Linux shared libraries and kernel modules files stores in /lib directory. These important Linux dynamic libraries are required to boot the system and run commands in the root file system.


/lost+found – Recovering Files

Sounds weird but yes we have lost+found in Linux file system structure. Every Linux file system and partitions has a lost+found in it’s directory. In the even your system is crashed or unexpected shutdown, you can run fsck command to check and repair the filesystem, fsck will turn any corrupted or almost-deleted files back into files that you can recover them later in /lost+found directory.


/media – Removable Media Devices

Every time you insert a removable device such as external hard drive, floppy disk, zip drive, CDs, DVDs, flash drive to a Linux system, a new directory will automatically be created inside the /media directory. /media directory is a temporary mount directory for removable devices.


/mnt – Temporarily mounted filesystems

While /media is where the system automatically mounts removable media, /mnt is for you to mount things (partitions, file systems, devices) manually and temporarily.


/opt – Optional software packages

The /opt directory is reserved to store addition software or extra and third-party software for your system, those addition software usually don’t follow the standard file system hierarchy and not handled by the package manager.


/proc – Kernel & Process Information

Similar to /dev, /proc directory contains information about running process, system resources and information. You can view information about any running process with a specific process-id (pid) or hardware’s information such as memory, cpu, io, etc…


/root – Root Home Directory

Don’t be confused with “/” or root directory, /root is a root account’s home directory determined by developer or local preference rather than /home/root to allow for booting the system even if /home/ is not available.


/sbin – System binaries

Similar to /bin, /sbin contains essential binaries that are generally intended to be run by the root user for system administration and maintenance purpose. For example: iptables, reboot, fdisk, ifconfig, swapon, init, ip, mount


/selinux – Security-Enhanced Linux

Selinux comes with RedHat based distro (fedora, centos), selinux is a security architecture integrated into the 2.6.x kernel using the Linux Security Modules (LSM). For some reason Centos 6 created an emtpry selinux directory in root directory, the real selinux directory with its configuration files are stored in /etc/selinux/ directory.


/srv – Service Data

Server (srv) contains data of services such as HTTP, FTP, rsync, cvs


/sys – virtual filesystem

Some newer Linux distros have /sys directory with sysfs virtual filesystem to store information and statistics about (physical and virtual) device and device names. /sys is newly added since Linux kernel 2.6 /sys contains similar information with /proc which display device information about the kernel’s view of the system.


/tmp – Temporary files

System’s Temporary Directory, all users and programs in your system can access/read/write in this directory. You should not save/store any important files/directories under /tmp since all files will be removed after system is rebooted.


/usr – binaries, documentation, source code, libraries

Pronounced as ‘user’, /usr contains the majority of user utilities, programs, libraries, documentation etc for all user-related second level programs rather than applications and files used by the system.


/var – Variable Files

Variable or /var contains data that is expected to change and grow as the system is running (log, mail, spool, temp)








Ref:http://www.namhuy.net/3230/linux-file-system-structure.html

Monday 3 November 2014

Error: Cannot retrieve metalink for repository: epel. Please verify its path and try again

 Error: Cannot retrieve metalink for repository: epel. Please verify its path and try again

 

Download epel Repo for CentOS 6:

 
[root@localhost]# wget http://dl.fedoraproject.org/pub/epel/6/x86_64/epel-release-6-8.noarch.rpm
[root@localhost]# rpm -Uvh epel-release-6*.rpm


[root@localhost]# yum repolist

Loaded plugins: fastestmirror
Loading mirror speeds from cached hostfile
Error: Cannot retrieve metalink for repository: epel. Please verify its path and try again

You Will get above Error.

Then Follow the Following Steps.

Edit Repo & Change https to http for [epel],[epel-debuginfo] & [epel-source].

Only Replace https to http, rest all line keep as it is
 

[root@localhost]# vim /etc/yum.repos.d/epel.repo


[epel]
mirrorlist=http://mirrors.fedoraproject.org/metalink?repo=epel-6&arch=$basearch

[epel-debuginfo]
mirrorlist=http://mirrors.fedoraproject.org/metalink?repo=epel-debug-6&arch=$basearch

[epel-source]

mirrorlist=http://mirrors.fedoraproject.org/metalink?repo=epel-source-6&arch=$basearch



[root@localhost]#  yum repolist

Loaded plugins: fastestmirror, refresh-packagekit, security
Loading mirror speeds from cached hostfile
epel/metalink                                                                                                          | 5.2 kB     00:00    
epel-source/metalink                                                                                                   | 5.2 kB     00:00    
 * base: mirror.nbrc.ac.in
 * epel: kartolo.sby.datautama.net.id
 * epel-source: kartolo.sby.datautama.net.id
 * extras: mirror.nbrc.ac.in
 * updates: mirror.nbrc.ac.in
base                                                                                                                   | 3.7 kB     00:00    
base/primary_db                                                                                                        | 4.6 MB     00:06    
epel-source                                                                                                            | 3.7 kB     00:00    
epel-source/primary_db                                                                                                 | 1.8 MB     00:06    
extras                                                                                                                 | 3.3 kB     00:00    
extras/primary_db                                                                                                      |  19 kB     00:00    
updates                                                                                                                | 3.4 kB     00:00    
updates/primary_db                                                                                                     | 171 kB     00:00    
repo id                                       repo name                                                                                 status
base                                          CentOS-6 - Base                                                                            6,518
epel                                          Extra Packages for Enterprise Linux 6 - x86_64                                            11,148
epel-source                                   Extra Packages for Enterprise Linux 6 - x86_64 - Source                                        0
extras                                        CentOS-6 - Extras                                                                             15
updates                                       CentOS-6 - Updates                                                                           209
repolist: 17,890

Tuesday 21 October 2014

SSH & SCP Slow Login Fix

SSH & SCP Slow Login Fix

Little clarification for the options.
Those that used useDNS have totally different issue than
what is solved by GSSAPIAuthentication. When you log using SSH, the
server does multiple operations.

One of it is to try to reverse resolve your IP to fetch your hostname.
Why? Developer knows, but I strongly suspect host specific
configuration (i.e hosts.deny).
So if your server is unable to reach
the DNS server (for any reason), the ssh daemon tries to reverse
lookup and wait until it times out (~30 seconds). The useDNS yes
(which is also the default behavior if commented) controls this
behavior. If set to useDNS no, then the reverse lookup doesn’t occur
and the IP is used. BEWARE: This is like patching an intense bleeding.
If this is your issue, then your DNS/network configuration is probably
wrong and should be repaired, not patched. Use the useDNS only for
server that shouldn’t/doesn’t have a DNS.

The GSSAPIAuthentication is a totally different issue. This flag tells
SSH to use a GSSAPI server to validate the authentication (from my
understanding). As for the DNS issue, if you do not have such a
server, it will wait until time out before processing further (~30
secondes). The GSSAPIAuthentication is the flag that controls this
behavior. Contrary to the useDNS flag, the GSSAPIAuthentication is
defaulted to no. Commenting it out will prevent the server from trying
to reach that server.

So both have the same symptoms ~30 login delay) caused by the same
reason (server connection time out) but they do NOT try to reach the
same server. To determine which one is required for you, do as the
article states (ssh -vvv ) and look where it froze. If the issue is


On fresh installed Linux servers you might have encountered that it takes quite some time before you get to see the
password prompt when you connect using SSH. 

As soon as you entered the password everything is lightning fast.
There are two items that might cause this problem:

    DNS Resolving
    Authentication methods that are not supported.


---------------------
DNS Resolving
---------------------


The DNS problem is easy to fix, make sure the SSH server is able to resolve DNS queries by configuring a DNS server.
Here’s how to do it on a CentOS server:

[root@server ~]# vim /etc/resolv.conf

And add the following lines:

nameserver 8.8.8.8
nameserver 8.8.8.8

I’m using the DNS servers from OpenDNS, use any server you like. This will allow your server to perform DNS lookups.
You can also tell SSH to disable DNS lookups like this:

[root@server ~]# vim /etc/ssh/sshd_config

And change the “UseDNS yes” field to “UseDNS no”.

This will ensure that SSH doesn’t try to do any reverse lookups.
Don’t forget to restart SSH! If your SSH connection time is still slow after these changes, read on…





---------------------
Authentication
---------------------


SSH supports a number of authentication methods besides username/password.
Let me show you what is happening behind the scenes when you are waiting for the password prompt:

deven@host ~ $ ssh -v root@192.168.1.100


I’m going to connect to a SSH server but I’ll use the “v” parameter (verbose). Here’s what you will see:

debug1: Authentications that can continue: publickey,gssapi-keyex,gssapi-with-mic,password


debug1: Next authentication method: gssapi-keyex
debug1: No valid Key exchange context
debug1: Next authentication method: gssapi-with-mic
debug1: Unspecified GSS failure.  Minor code may provide more information
Cannot determine realm for numeric host address

debug1: Unspecified GSS failure.  Minor code may provide more information
Cannot determine realm for numeric host address

debug1: Unspecified GSS failure.  Minor code may provide more information

debug1: Unspecified GSS failure.  Minor code may provide more information
Cannot determine realm for numeric host address

debug1: Next authentication method: publickey
debug1: Trying private key: /home/host/.ssh/id_rsa
debug1: Trying private key: /home/host/.ssh/id_dsa
debug1: Trying private key: /home/host/.ssh/id_ecdsa
debug1: Next authentication method: password


Before it shows you the password prompt, SSH will first try to connect using GSSAPI-KEYEX, GSSAPI-WITH-MIC and Public Key.
Since I’m not using these it’s causing a delay when trying to connect to SSH.
Especially the GSSAPI-WITH-MIC is taking a long time…let’s disable it:

[root@server ~]# vim /etc/ssh/sshd_config

Now change the “GSSAPIAuthentication yes” line to “GSSAPIAuthentication no”.



Restart SSH and try to connect again:

deven@host ~ $ssh -v root@192.168.1.100

debug1: Authentications that can continue: publickey,password
debug1: Next authentication method: publickey
debug1: Trying private key: /home/renemolenaar/.ssh/id_rsa
debug1: Trying private key: /home/renemolenaar/.ssh/id_dsa
debug1: Trying private key: /home/renemolenaar/.ssh/id_ecdsa
debug1: Next authentication method: password





With GSSAPI disabled it’s flying!

In case you are wondering, GSSAPI stands for Generic Security Services API and is a standard interface so SSH can communicate with Kerberos.




Thursday 16 October 2014

Argument list too long Issue in Linux


Argument list too long Issue in Linux
Argument list too long” a simple solution

I was trying to delete a client’s all bounce emails and rm -rf didn’t help me at this point



First of Check the default value of argument list for your server:

root@server:~# getconf ARG_MAX
2621440

And you can sipmly increase this value by typing:
root@server:~# ulimit -s 665536

So you will see that argument list size increases by re-typing:
root@server:~# getconf ARG_MAX
170377216

Most useful Linux Commands

 Most useful Linux Commands


========================================================================================================
 Most useful Linux Commands
========================================================================================================
ls     ------------------------------ List all files and directories
ls -l  ------------------------------ List all files and directories with some extra information
dir  ------------------------------  Display directories
mkdir <name> ------------------------------ Create a directory
mkidr -p <dir_name1>/<dir_name2>------------------------------Create multiple directories
rmdir <dir_name>------------------------------Remove an empty directory
rm <file_name>------------------------------Remove a file/directory with confirmation
rm -rf <file/dir_name>------------------------------Remove file/directory without confirmation
cat <file_name>------------------------------View a file
cat > <file_name>------------------------------Create a new file and edit it
touch <file_name>------------------------------Create a file
vi <file_name>------------------------------File editor
vim <file_name>------------------------------File editor
command >file_name------------------------------Write output of the command into the file
cd      ------------------------------Change directory
cd ..   ------------------------------Move one directory back
cd -    ------------------------------Move to previous directory
cd ~    ------------------------------Move to current user’s home directory
cd /home/me ------------------------------Move to /home/me directory
shutdown -h now ------------------------------Shuts the system down to halt immediately.
shutdown -r now ------------------------------Shuts the system down immediately and the system reboots.
mv -i myfile yourfile ------------------------------Move the file from “myfile” to “yourfile”. This effectively changes the name of “myfile” to “yourfile”.
mv -i /data/myfile .  ------------------------------Move the file from “myfile” from the directory “/data” to the current working directory.
echo <text>  ------------------------------Display the text
find              ------------------------------Search for files in a directory hierarchy
locate           ------------------------------Search for files in a directory hierarchy
grep             ------------------------------Depth Search
wc               ------------------------------Word count
kill               ------------------------------To kill a process
reboot         ------------------------------Reboot the system
poweroff     ------------------------------poweroff the system
mount          ------------------------------mount a partition
umount        ------------------------------unmount a partition
fdisk -l        ------------------------------Partition manipulator



========================================================================================================
System Informations
========================================================================================================
pwd  ------------------------------Prints present working directory
hostname ------------------------------Prints hostname
uname    ------------------------------ prints the name of OS
whoami  ------------------------------ Prints your login name
date       ------------------------------ Prints system date
cal <year> ------------------------------Prints calendar of the year
who          ------------------------------ Determine the users logged on the machine
w             ------------------------------  Determine who is logged on the system
rwho -a   ------------------------------   Determine the remote users
finger <user_name>  ------------------------------System info about user
last     ------------------------------Show list of users last logged-in on your system
lastb   ------------------------------Show last unsuccessful login attempts on your system
history  ------------------------------Show the used commands
history -c ------------------------------Clears all history
comman    ------------------------------Run the most recent command from the bash history commands that start with the string “ comman “
uptime  ------------------------------Display the system uptime
ps    ------------------------------Process status
ps -aux | more ------------------------------ List all the currently running process
top        ------------------------------ List the currently running process, sorted by CPU usage
gtop, ktop, htop   ------------------------------ GUI choice for top
arch       ------------------------------ Display the system architecture
Xorg -version    ------------------------------ Show the version of X windows I have on my system
cat /etc/issue ------------------------------ Check what distribution you are using
free -m    ------------------------------ Check your usage, free memory of primary memory
df -h   ------------------------------ Disk free information in human readable form
du / -bh | more   ------------------------------ Print detailed disk usage for each sub-directory starting at the “/” (root) directory
cat /proc/cpuinfo ------------------------------ Displays cpu information
cat /etc/interrupts ------------------------------ List the interrupts in use
cat /proc/version ------------------------------ Linux version and other info
cat /proc/filesystems ------------------------------ Show the type of filesystem currently in use
cat /etc/printcap | less ------------------------------ Show the setup of printers
lsmod   ------------------------------ Show the currently loaded kernel modules
set | more ------------------------------ Show the current user environment
env | more ------------------------------ Show environment variables
dmesg | less ------------------------------ Print kernel messages
chage -l <user_login_name>  ------------------------------See my password expiry information
chage username   ------------------------------ Change User's Expiry
quota    ------------------------------ Display my disk quota
sysctl -a | more ------------------------------ Display  all the configurable Linux kernel parameters
runlevel    ------------------------------ Print the previous and current runlevel



========================================================================================================
IP tables
========================================================================================================
iptables –L ------------------------------ Lists the current filter rules
iptables –F ------------------------------ Flush the rules temporarily / Disable the rules temporarily
iptables –h ------------------------------ Prints help information



========================================================================================================
Networking
========================================================================================================
ifconfig ------------------------------ Displays all the interface information
ifstat ------------------------------ Check the current network usage
iptraf  ------------------------------ A network utility allows you check the network activities
ifup ------------------------------ Bring a network interface up
ifdown  ------------------------------ Bring a network interface down



========================================================================================================
Help
========================================================================================================
man <command_name> ------------------------------ Display man pages of the command
<command_name> –help ------------------------------ Command help
info <command_name> ------------------------------ Helping command
whatis <command_name> ------------------------------ Display man pages description




========================================================================================================
Compress and decompress
========================================================================================================
tar –cvf <file_name.tar> <file_name_1> <file_name_2> . .   ------------------------------ Compress files
tar –xvf <file_name.tar>     ------------------------------ Decompress the compressed file
tar –xvf <file_name.tar> – C <location>   ------------------------------ Decompress files to desired location
tar –zcvf <file_name.tar.gz> <file_name_1> <file_name_2>  ------------------------------ Compress files with gz
tar –zxvf <file_name.tar.gz> ------------------------------ Decompress the compressed gz files
tar –zxvf <file_name.tar.gz> -C <location> ------------------------------ Decompress files to desired location




========================================================================================================
apt-get commands
========================================================================================================
apt-get install <package_name> ------------------------------ Installing package(s)
apt-get remove <package_name>  ------------------------------ Removing package(s)
apt-get update  ------------------------------ Update the repository
apt-cdrom add  ------------------------------ Add CD ROM archives to repository
apt-cdrom ident ------------------------------ Identify CD-ROM disk
apt-get  -d install <package_name> ------------------------------ Download packages, no installation or unpacking
apt-get –purge remove <package_name>--------- Remove all traces of a package, incl. Configuration files etc.,
apt-get –u update ------------------- Upgrades all installed packages, but does not remove any packages to resolve dependencies
apt-get –u dist-upgrade -------------- Upgrades all the installed packages, removes or installs packages as needed to satisfy all dependencies
apt-cache search <package_name> -------------------- Search package in the cache
apt-get check ------------------------------ Check broken dependencies
apt-cache autoclean ------------------------------ Remove cached packages that are no longer needed
apt-cache clean  ------------------------------ Remove all cached packages
apt-get help ------------------------------ Help



========================================================================================================
dpkg commands
========================================================================================================
dpkg –l ------------------------------ List all the installed packages
dpkg –L  <package_name>------------------------------ List files belonging to a package
dpkg –S <file_name> ------------------------------ To See which package a file belongs to
dpkg –s <package_name>------------------------------ To show complete package information
dpkg –yet-to-unpack  ------------------------------ To look for downloaded, uninstalled packages
dpkg –audit ------------------------------ Show partially installed packages
dpkg -i <package> ------------------------------ Install a new package
dpkg -r <package> ------------------------------ Remove a package



========================================================================================================
Yum Commands
========================================================================================================
yum list [available|installed|extras|updates|obsoletes|all|recent] [pkgspec]
yum list ------------------------------ List packages enabled in the repository
yum list all ------------------------------ List packages enabled in the repository
yum list available ----Lists all the packages available to be installed in any enabled repository on your system
yum list installed -------------------------- Lists all the packages installed on the system
yum list extras -------- Lists any installed package which no longer appears in any of your enabled repositories
yum list obsoletes ------Lists any obsoleting relationships between any available package and any installed package
yum list updates -----Lists any package in an enabled repository which is an update for any installed package
yum list recent -----------------Lists any package added to any enabled repository in the last seven(7) days
yum list pkgspec ---------------------Refine your listing for particular packages
yum check-update -----------------------It returns an exit code of 100 if there are any updates available
yum info -----------------------------Displays information about any package installed or available
yum search ------------------------------ Search and list the packages
yum provides/yum whatprovides Searches for which packages provide the requested dependency of file and also takes wildcards for files
yum clean  ------------------------- Clean up the cache of metadata and packages
yum clean packages ----------Cleans up any cached packages in any enabled repository cache directory
yum clean metadata -------Cleans up any xml metadata that may have been cached from any enabled repository
yum clean dbcache ---------------- Clean up the cached copies of those from any enabled repository cache
yum clean all ------------------------------ Clean all cached files from any enabled repository



========================================================================================================
RPM Commands
========================================================================================================
rpm –ivh <package_name>--------------------- Install a new package
rpm –Uvh <package_name>------------------- Update an already installed package
rpm –e<package_name> -------------------------- Remove a package
rpm –aq ------------------------------  To list all rpm packages installed on your system
rpm –F <package_name> ------------------------------ Freshening up the already installed package
rpm –version ------------------------------  Prints rpm version



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

Tuesday 14 October 2014

Protect a shell script with password

   How to protect a shell script with password 


Add following container before Your Shell Script or Any file which u want to Protect.

realpswd="Devendra"
read -s -p "Type Your Password: " pass
echo ""

[ "$pass" != "$realpswd" ] && echo "Wrong Password.. exiting..." && exit || echo "Continue"



 

--------------------------------------------------------------------------------------------------------------

For Ex. There is an example script.


root@devendra-desktop:~#vi deva.sh        #Paste Following Container to Your Shell Script#

realpswd="Devendra"
read -s -p "Type Your Password: " pass
echo ""

[ "$pass" != "$realpswd" ] && echo "Wrong Password.. exiting..." && exit || echo "Continue"
#!/bin/bash

echo -n "How many random numbers do you want to generate? "
read max

for (( start = 1; start <= $max; start++ ))
do
  echo -e $RANDOM
done



root@devendra-desktop:~#chmod a+x deva.sh
root@devendra-desktop:~#chmod ./deva.sh

root@devendra-desktop:~# ./deva.sh
Type Your Password:






####This protects your script from other users except root:

root@devendra-desktop:/opt# chmod 700 deva.sh


--------------------------------------------------------------------------------------------------------------
--------------------------------------------------------------------------------------------------------------

Saturday 4 October 2014

Change the MySQL root Password

How to Change the MySQL root Password in Linux or OSX via Command Line



If you have forgot the MySQL root password, can’t remember 
And want to break in…..



Stop MySQL

root@server:~# /usr/local/mysql/support-files/mysql.server stop

                                                   OR
root@server:~# /etc/init.d/mysqld stop
   

Start it in safe mode:
root@server:~# mysqld_safe --skip-grant-tables




This will be an ongoing command until the process is finished so open another shell/terminal window, log in without a password:


root@server:~# mysql -u root -p
Enter password:
Welcome to the MySQL monitor.  Commands end with ; or \g.
Your MySQL connection id is 2
Server version: 5.1.73 Source distribution

Copyright (c) 2000, 2013, Oracle and/or its affiliates. All rights reserved.

Oracle is a registered trademark of Oracle Corporation and/or its
affiliates. Other names may be trademarks of their respective
owners.

Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.

mysql>


mysql> UPDATE mysql.user SET Password=PASSWORD('password') WHERE User='root'; 
mysql> Change the lowercase password to what you want – with single quotes.
 

mysql> FLUSH PRIVILEGES;mysql> quit

   



Start MySQL

 
root@server:~# /usr/local/mysql/support-files/mysql.server start

                          OR 
root@server:~# /etc/init.d/mysqld start
 



























































































































































































































Sunday 28 September 2014

Shellshock vulnerability in bash

Shellshock is a vulnerability in GNU's bash shell that gives attackers access to run remote commands
on a vulnerable system. If your system has not updated bash in since Sun Sep 28 2014: 1:11AM EST,
you're most definitely vulnerable and have been since first boot.
    Certain services and applications allow remote unauthenticated attackers to provide environment variables,
allowing them to exploit this issue.
    The Shellshock vulnerability can be exploited on systems that are running Services or applications
that allow unauthorized remote users to assign Bash environment variables. Examples of exploitable systems
include the following:

  • Apache HTTP Servers that use CGI scripts (via mod_cgi and mod_cgid) that are written in Bash or launch to Bash sub-shells
  • Certain DHCP clients
  • Open SSH servers that use the ForceCommand capability
  • Various network-exposed services that use Bash



There are a few different ways to test if your system is vulnerable to shellshock. Try running the following command in a shell.
 

#env x='() { :;}; echo vulnerable' bash -c "echo this is a test"
If you see "vulnerable" you need to update bash. Otherwise, you should be good to go.



CentOS, Ubuntu, Linux systems
Shellshock is a vulnerability in bash. In order to patch your vulnerable system, you will need
to get the most up to date version of bash available from GNU.org.

Depending on your package manager (yum, apt-get, etc) you may be able to just run a yum update
and you'll be good to go.


Patch your system
For CentOS, Fedora, Red Hat (and the like) users, justto update it
In order to update to the most recent version of the Bash package run the following command:


you can also retrieve Bash version using any of these commands:

#rpm -q bash
#yum info bash
#yum list installed bash


If the output shows version older than 4.1.2-15.el6_5.1, you’d need upgrade bash to its most recent version. If that’s the case, then execute the following YUM command:



CentOS /RedHat  

#yum clean all; yum update bash
 
For Ubuntu Systems:
#apt-get update; apt-get upgrade;
 

For Arch Linux:
#pacman -Syu


If your package manager doesn't find an update, you will need to build bash from src.
Building From Source

#curl https://shellshocker.net/fixbash | sh
#cd ~/
#mkdir bash
#cd bash
#wget https://ftp.gnu.org/gnu/bash/bash-4.3.tar.gz
#tar zxvf bash-4.3.tar.gz
#cd bash-4.3
#./configure && make && make install



Perform a system reboot [might not need a reboot] OR
if system cannot be reboot, run command

#/sbin/ldconfig

No need to reboot your system either. Rebooting may be necessary only if someone has already
taken control of your machine because of the bug.
But in such a case, you should reinstall your system

If you have a strong reason to suspect that a system was compromised by this vulnerability then
a system reboot should be performed after the update is installed as a best security practice
and security checks should be analyzed for suspicious activity.



 

Test your system 

To test your system, log into your bash shell and type:

#env x='() { :;}; echo vulnerable' bash -c "echo this is a test"

If you see “vulnerable” afterwards, you haven’t patched it.

If you see “this is a test”, you’re patched.


OS X 

If you're running OS X, you will need to download and compile bash yourself using brew or MacPorts.

We recommend using brew - Go to http://brew.sh/ and install brew on your system.

Once you have brew installed, run the following commands to update your system

brew update
brew install bash
sudo sh -c 'echo "/usr/local/bin/bash" >> /etc/shells'
chsh -s /usr/local/bin/bash
sudo mv /bin/bash /bin/bash-backup
sudo ln -s /usr/local/bin/bash /bin/bash


If you're using MacPorts, run the following:

sudo port self update
sudo port upgrade bash

Once you've updated, try the exploit again and report back your findings






Ref Sites :

https://access.redhat.com/articles/1200223
http://www.linuxbrigade.com/bash-shellshock-bug-find-youve-tested/
http://www.joe0.com/2014/09/24/how-to-fix-the-bash-software-bug-biggest-threat-since-heartbleed-on-fedora-centos-red-hat-scientific-linux-yellow-dog-linux-oracle-linux-systems/
https://access.redhat.com/articles/1200223
http://stevejenkins.com/blog/2014/09/how-to-manually-update-bash-to-patch-shellshock-bug-on-older-fedora-based-systems/
http://www.lynda.com/articles/shellshock-bash-exploit
http://www.engadget.com/2014/09/25/what-is-the-shellshock/
http://lists.centos.org/pipermail/centos-announce/2014-September/020593.html
http://lists.centos.org/pipermail/centos-announce/2014-September/020591.html
http://www.troyhunt.com/2014/09/everything-you-need-to-know-about.html
http://timesofindia.indiatimes.com/tech/tech-news/Security-experts-expect-Shellshock-software-bug-to-be-significant/articleshow/43657819.cms
https://access.redhat.com/articles/1200223

Tuesday 16 September 2014

CentOS 7 for 64bit Released

The CentOS Project Team is pleased to announce the immediate availability of CentOS 7 for x86_64. This is the first release for CentOS-7 and is version marked as 7.0-1406. CentOS is an Enterprise-class Linux Distribution derived from sources freely provided to the public by Red Hat.

 
For the first time, this release was built from sources hosted at git.centos.org, however srpms being a byproduct of the build and also considered critical in the code and buildsys process are being published to match every rpm we release. Sources will be available from vault.centos.org in their own dedicated directories to match the corrosponding binary rpms.
For the first time, there is a supported upgrade path from CentOS-6 to CentOS-7. This path is only supported from the latest version of CentOS-6 (being 6.5 at the time of writing) to the latest version of CentOS-7. The tools needed for this functionality are still being tested and will be released at a later time.
There are many fundamental changes in this release, compared to previous releases of CentOS. Notably the inclusion of systemd, Gnome3, and a default filesystem of XFS. Most notable changes are:
  • Kernel updated to 3.10.0
  • Support for Linux Containers
  • Open VMware Tools and 3D graphics drivers out of the box
  • OpenJDK-7 as default JDK
  • In Place Upgrade from 6.5 to 7.0 (as already mentioned)
  • LVM-snapshots with ext4 and XFS
  • Switch to systemd, firewalld and GRUB2
  • XFS as default file system
  • iSCSI and FCoE in kernel space
  • Support for PTPv2
  • Support for 40G Ethernet Cards
  • Supports installations in UEFI Secure Boot mode on compatible hardware


Download ISO Files
Click button below and select from the list of mirrors closest to you to make it faster for download

 













 Ref: http://www.sysads.co.uk/2014/07/centos-7-for-64bit-released/





Change interface name “eth0″ in CentOS 7

Change the default network interface name to “eth0″


CentOS7 has a default nic name as “en016…..”, like this. To change it back to the default network device name like “ethX”, edit the grub file:


# vi /etc/default/grub

Search for the line “GRUB_CMDLINE_LINUX” and append the following: “net.ifnames=0 biosdevname=0


GRUB_TIMEOUT=5
GRUB_DISTRIBUTOR="$(sed 's, release .*$,,g' /etc/system-release)"
GRUB_DEFAULT=saved
GRUB_DISABLE_SUBMENU=true
GRUB_TERMINAL_OUTPUT="console"
GRUB_CMDLINE_LINUX="vconsole.font=latarcyrheb-sun16 vconsole.keymap=us rd.lvm.lv=centos/root crashkernel=auto rhgb quiet"
GRUB_DISABLE_RECOVERY="true"


Then it Will look like this:



GRUB_TIMEOUT=5
GRUB_DISTRIBUTOR="$(sed 's, release .*$,,g' /etc/system-release)"
GRUB_DEFAULT=saved
GRUB_DISABLE_SUBMENU=true
GRUB_TERMINAL_OUTPUT="console"
GRUB_CMDLINE_LINUX="vconsole.font=latarcyrheb-sun16 vconsole.keymap=us rd.lvm.lv=centos/root crashkernel=auto rhgb quiet net.ifnames=0 biosdevname=0"
GRUB_DISABLE_RECOVERY="true"




Create a new configuration based on the currently running system using grub2-mkconfig command:
# grub2-mkconfig -o /boot/grub2/grub.cfg



Rename the interface files by renaming the file “/etc/sysconfig/network-scripts/ifcfg-en01…
# sudo mv /etc/sysconfig/network-scripts/ifcfg-eno16777736 /etc/sysconfig/network-scripts/ifcfg-eth0

Reboot the system:

# reboot


After reboot, check the interface name:

# ifconfig

eth0: flags=4163<UP,BROADCAST,RUNNING,MULTICAST> mtu 1500
inet 192.168.1.100 netmask 255.255.255.0 broadcast 192.168.58.255
inet6 fe80::20c:29ff:fe6e:b0ae prefixlen 64 scopeid 0x20<link>
ether 00:0c:29:6e:b0:ae txqueuelen 1000 (Ethernet)
RX packets 25336 bytes 2829386 (2.6 MiB)
RX errors 0 dropped 11 overruns 0 frame 0
TX packets 172 bytes 35789 (34.9 KiB)
TX errors 0 dropped 0 overruns 0 carrier 0 collisions 0

Wednesday 10 September 2014

Tips & Tuning history file.

7 Tips that can help you to improve you Bash history file.
You will learn how to add date and time to bash history file, increase history size, ignore specific commands and much more ..


1. Add Date and Time to Bash History

Sometimes it would be very nice to know when some command got executed.
Set HISTTIMEFORMAT to print the time stamps associated with each history entry.
Append the following line to ~/.bashrc file :

 export HISTTIMEFORMAT="%h %d %H:%M:%S "

Now, when you type history, it will show something like :

113  Jun 08 16:31:06 sudo ifconfig
114  Jun 08 16:31:10 top
115  Jun 08 16:31:19 ping 8.8.8.8
116  Jun 08 16:31:22 history

2. Increase Bash History Size

Increase HISTSIZE - the number of commands to remember in the command history (the default value is 500).
 
export HISTSIZE=10000


Increase HISTFILESIZE - the maximum number of lines contained in the history file (the default value is 500).
 
export HISTFILESIZE=10000

 

 3. Append Bash Commands to History File

Bash overwrites .bash_history file?

 
shopt -s histappend

4. Store Bash History Immediately

By default, Bash only records a session to the .bash_history file when the session terminates.
This means that if you crash or your session terminates improperly, you lose the history up to that point.
Use $PROMPT_COMMAND variable to save each command right after it has been executed.
Append the following line to ~/.bashrc file, if the variable $PROMPT_COMMAND hasn't been set yet :
 
PROMPT_COMMAND='history -a'



Append the following line, if the variable $PROMPT_COMMAND has already been set :
PROMPT_COMMAND='$PROMPT_COMMAND; history -a'

 

 

5. Control Bash History

HISTCONTROL is a colon-separated list of values controlling how commands are saved in the history file.
Value Description
ignorespace don't save lines which begin with a <space> character
ignoredups don't save lines matching the previous history entry
ignoreboth use both 'ignorespace' and 'ignoredups'
erasedups eliminate duplicates across the whole history
Example :
 
export HISTCONTROL=ignorespace:erasedups

 

 

6. Ignore Specific Commands

HISTIGNORE is a colon-separated list of patterns used to decide which command lines should be saved in the history file.
Don't save ls, ps and history commands :
 
export HISTIGNORE="ls:ps:history" 



 Don't save commands with s in the beginig :

export HISTIGNORE="s*"

 

 

7. Use one command per line

Store multi-line commands in one history entry :
shopt -s cmdhist

 

 Change the History File Name

Use HISTFILE to change the name of the file in which Bash history is saved. The default value is ~/.bash_history.
 
export HISTFILE=~/.custom_file