Showing posts with label Linux. Show all posts
Showing posts with label Linux. Show all posts

Dec 13, 2013

How to Fix error 'Could not determine the server's fully qualified domain name, using 127.0.0.1 '

Problem:

[root@spa ~]# service httpd start
Starting httpd: httpd: Could not determine the server's fully qualified domain name, using 127.0.0.1 for S erverName
                                                           [  OK  ]
[root@spa ~]#

solution:

Edit /etc/httpd/conf/httpd.conf
and search for ServerName and add
ServerName localhost

How to overwrite symbolic links in unix

You can overwrite symbolic links by using -f to the default command

Example
mohan@mysys /cygdrive/c/
$ ln -s /tmp/test.sh tumba
mohan@mysys /cygdrive/c/
$ ls -l
total 80
lrwxrwxrwx  1 mohan        Domain Users    5 Oct  9 14:59 tumba -> /tmp/test.sh
mohan@mysys /cygdrive/c/
$ ln -s /tmp/build_env.log  tumba
ln: failed to create symbolic link `tumba': File exists
mohan@mysys /cygdrive/c/


 Now we can overwrite the existing symbolic link by using -f







$ ln -s -f /tmp/build_env.log  tumba
mohan@mysys /cygdrive/c/
$ ls -l
total 80
lrwxrwxrwx  1 mohan        Domain Users    5 Oct  9 14:59 tumba -> /tmp/build_env.log

How to Unmount an ISO in linux

To see the list of currently mounted file systems,

#mount

To unmount a mounted iso,






# umount /mnt/iso

assuming that your image is mounted at /mnt/iso

How to mount ISO in Linux using command line

Procedure to mount ISO images under Linux

As Root

1)Create some directory to mount the iso so that you can view it as a regular directory.

             # mkdir -p /mnt/disk

2) Use mount command as follows to mount iso file called disk1.iso:

             # mount -o loop disk1.iso /mnt/disk

Now to see the contents of iso file, Change directory to list files stored inside an ISO image:
            # cd /mnt/disk
            # ls -l


More about loop device

A loop device is a pseudo-device that makes a file accessible as a block device. Loop devices are often used for CD ISO images and floppy disc images. Mounting a file containing a filesystem via such a loop mount makes the files within that filesystem accessible. They appear in the mount point directory using above commands.

how to add files under apache server

In Apache server, add your contents under a directory and create symlink to it under /var/www/html/

or

move your directory under /var/www/html/

How to send mail in linux

mail -s "Hello world" mohan@yahoo.com

Use Control+D to move next item

Apr 17, 2013

error C4335: Mac file format detected: please convert the source file to either DOS or UNIX format

Problem:
error C4335: Mac file format detected: please convert the source file to either DOS or UNIX format

Solution:
if you are compiling in cygwin or unix\linux you can apply dos2uinx on files to remove this issue.


mohan@MOHANTL1C ~
$ dos2unix.exe test.txt
dos2unix: converting file test.txt to Unix format ...

Feb 26, 2013

How to find a system 32 or 64 bit

In any Linux variants either one of this should work ( Redhat, Cent-Os, Ubuntu, Hp-ux, Solaris etc )

[mohan@chinna ~]$ arch
x86_64
[mohan@chinna ~]$ uname -m
x86_64
[mohan@chinna ~]$ getconf LONG_BIT
64


As you can guess, 64 / x86_64 is 64bit system, whereas 32 / i386 / i686  denotes its a 32 bit sytem.


For windows
Right-click MyComputer->Properties

It will bring a window like below image, from that you can check the system type

Feb 25, 2013

How to edit iptables in linux

Problem:
sometimes you may receive below error like

The description for Event ID ( 0 ) in Source ( sshd ) cannot be found. The local computer may not have the necessary registry information or message DLL files to display messages from a remote computer. You may be able to use the /AUXSOURCE= flag to retrieve this description; see Help and Support for details. The following information is part of the event: sshd: PID 2992: Accepted publickey for build from 10.69.250.31 port 33344 ssh2.

Solution :
Either Turn off the firewall in linux or add the port 22 as exception in iptables

To disable selinux  edit /etc/sysconfig/selinux    and set SELINUX to disabled.

SELINUX=disabled

I've encountered such problems when the binaries and libraries were not
executable by SYSTEM.
"chmod 755 /usr/sbin/* /usr/bin/*" fixed the problem.

If the problem still exists, add the port to the iptables.

For adding port 22 to the iptables, from shell run

iptables -A INPUT -p tcp --dport 22 -j ACCEPT

or

edit /etc/sysconfig/iptables
and append this line

-A INPUT -p tcp --dport 22 -j ACCEPT
Save and close the file. Restart iptables:
/etc/init.d/iptables restart
or
service iptables restart
Learn more about iptables by
man iptables

Feb 24, 2013

How to add Gnome to a CentOS 6 minimal install

Problem:
sometimes you may receive below error like

The description for Event ID ( 0 ) in Source ( sshd ) cannot be found. The local computer may not have the necessary registry information or message DLL files to display messages from a remote computer. You may be able to use the /AUXSOURCE= flag to retrieve this description; see Help and Support for details. The following information is part of the event: sshd: PID 2992: Accepted publickey for build from 10.69.250.31 port 33344 ssh2.

Solution :
Either Turn off the firewall in linux or add the port 22 as exception in iptables

To disable selinux  edit /etc/sysconfig/selinux    and set SELINUX to disabled.

SELINUX=disabled

I've encountered such problems when the binaries and libraries were not
executable by SYSTEM.
"chmod 755 /usr/sbin/* /usr/bin/*" fixed the problem.

If the problem still exists, add the port to the iptables.

For adding port 22 to the iptables, from shell run

iptables -A INPUT -p tcp --dport 22 -j ACCEPT

or

edit /etc/sysconfig/iptables
and append this line

-A INPUT -p tcp --dport 22 -j ACCEPT

Feb 22, 2013

How to create checksums for all files recursively

To create checksums for all files recursively

find . -type f -exec md5sum "{}" +;

Feb 21, 2013

How to find a machine whether its a physical machine or a Virtual machine in linux.

You can get this information by using a tool called dmidecode. dmidecode  is a tool for dumping a computerâs DMI (some say SMBIOS) ta-
       ble contents in a human-readable format. This table contains a descrip-
       tion  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.

[root@server2 tmp]# /usr/sbin/dmidecode |grep -i "vm"
                Manufacturer: VMware, Inc.
                Product Name: VMware Virtual Platform
                Serial Number: VMware-24 34 c4 76 3b 1a 94 8d-99 08 5d cc 81 04                            17 25
                        VME (Virtual mode extension)
                        VME (Virtual mode extension)
                Description: VMware SVGA II
                String 1: [MS_VM_CERT/SHA1/27d66596a61c48dd323409dfd5126e33f59                           ae7]
               

               
For a physical machine it will be like below

[mohan@server2 storage]# sudo /usr/sbin/dmidecode |grep -i "vm"
                VME (Virtual mode extension)
                VME (Virtual mode extension)
               

Feb 15, 2013

mount error: can not change directory into mount target /mnt/server/


Problem:
mount error: can not change directory into mount target /mnt/server/

Reason:
Either you didn't create your /mnt/server directory or specified it wrong in your mount command.
check the existence of the directory and try the mount command again

Example:
[root@library 20100813143931]# mount -t cifs //192.168.1.2/Release -o username=mohan,domain=priv  /mnt/server/
mount error: can not change directory into mount target /mnt/server/
[root@library 20100813143931]# cd /mnt/server
-bash: cd: /mnt/server: No such file or directory
[root@library 20100813143931]# ls /mnt/
[root@library 20100813143931]# mkdir /mnt/server
[root@library 20100813143931]# mount -t cifs //192.168.1.2/Release -o username=mohan,domain=priv  /mnt/server/
Password:

Dec 6, 2012

How to query, install, upgrade or remove RPM in linux ?

Here we are first removing an existing rpm and installing the latest version.
For any of the action you should be either root or in the sudoers list.

To query for rpm
[root@system1 share]# rpm -qa | grep cmake cmake-2.6.4-5.el6.x86_64
To erase rpm
[root@system1 share]# rpm -e cmake-2.6.4-5.el6.x86_64
           [root@system1 share]# rpm -qa | grep cmake .
           [root@system1 share]#

To install rpm

           [root@system1 share]# rpm -i cmake-2.8.8-1.el6.rfx.x86_64.rpm
           warning: cmake-2.8.8-1.el6.rfx.x86_64.rpm: Header V3 DSA/SHA1 Signature, key ID 6b8d79e6: NOKEY
           [root@system1 share]# rpm -qa | grep cmake cmake-2.8.8-1.el6.rfx.x86_64
           [root@system1 share]#
or


remove it using yum


            [root@system1 share]# yum remove

Jul 25, 2012

How to find a machine whether its a physical machine or a Virtual machine in linux

You can get this information by using the unix utility, dmidecode.
dmidecode  is a tool for dumping a computerâs DMI (some say SMBIOS) ta-ble contents in a human-readable format. 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.

Note: This command should be used as root. or you can use "sudo" to execute it.


Sample Usage

In a virtual machine

[root@server2 tmp]# /usr/sbin/dmidecode |grep -i "vm"
                Manufacturer: VMware, Inc.
                Product Name: VMware Virtual Platform
                Serial Number: VMware-24 34 c4 76 3b 1a 94 8d-99 08 5d cc 81 04                            17 25
                        VME (Virtual mode extension)
                        VME (Virtual mode extension)
                Description: VMware SVGA II
                String 1: [MS_VM_CERT/SHA1/27d66596a61c48dd323409dfd5126e33f59                           ae7]
                
                
For a physical machine it will be like below

[mohan@server2 storage]# sudo /usr/sbin/dmidecode |grep -i "vm"
                VME (Virtual mode extension)
                VME (Virtual mode extension)
                

Aug 31, 2010

cd: error retrieving current directory: getcwd: cannot access parent directories: No such file or directory

Problem:
cd: error retrieving current directory: getcwd: cannot access parent directories: No such file or directory

Solution:
directory you are trying to access was deleted. change to some existing directory or type cd to return home directory

Nov 11, 2009

Linux Error - ssh: connect to host 10.10.25.5 port 22: Connection refused (or) How to configure ssh server in cygwin

Problem:
ssh: connect to host 10.10.25.5 port 22: Connection refused

Solution:
machine does not allows communiation through ssh. configure ssh server to allow communication through ssh
http://ist.uwaterloo.ca/~kscully/CygwinSSHD_W2K3.html

Sample ssh setup log
chmod +r /etc/passwd
chmod +r /etc/group
chmod 0775 /var

$ ssh-host-config
*** Query: Overwrite existing /etc/ssh_config file? (yes/no) yes
*** Info: Creating default /etc/ssh_config file
*** Query: Overwrite existing /etc/sshd_config file? (yes/no) yes
*** Info: Creating default /etc/sshd_config file
*** Info: Privilege separation is set to yes by default since OpenSSH 3.3.
*** Info: However, this requires a non-privileged account called 'sshd'.
*** Info: For more info on privilege separation read /usr/share/doc/openssh/READ
ME.privsep.
*** Query: Should privilege separation be used? (yes/no) yes
*** Info: Note that creating a new user requires that the current account have
*** Info: Administrator privileges.  Should this script attempt to create a
*** Query: new local account 'sshd'? (yes/no) yes
*** Info: Updating /etc/sshd_config file
*** Info: Added ssh to C:\WINDOWS\system32\driversc\services


*** Warning: The following functions require administrator privileges!

*** Query: Do you want to install sshd as a service?
*** Query: (Say "no" if it is already installed as a service) (yes/no) yes
*** Info: Note that the CYGWIN variable must contain at least "ntsec"
*** Info: for sshd to be able to change user context without password.
*** Query: Enter the value of CYGWIN for the daemon: [ntsec]

*** Info: The sshd service has been installed under the LocalSystem
*** Info: account (also known as SYSTEM). To start the service now, call
*** Info: `net start sshd' or `cygrunsrv -S sshd'.  Otherwise, it
*** Info: will start automatically after the next reboot.

*** Info: Host configuration finished. Have fun!

Nov 10, 2009

WARNING: POSSIBLE DNS SPOOFING DETECTED!

Error :
@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@$
@       WARNING: POSSIBLE DNS SPOOFING DETECTED!          @$
@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@$
The RSA host key for host1 has changed,$
and the key for the according IP address 10.10.25.5$
is unknown. This could either mean that$
DNS SPOOFING is happening or the IP address for the host$
and its host key have changed at the same time.$
@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@$
 @    WARNING: REMOTE HOST IDENTIFICATION HAS CHANGED!     @$
 @@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@$
 IT IS POSSIBLE THAT SOMEONE IS DOING SOMETHING NASTY!$
 Someone could be eavesdropping on you right now (man-in-the-middle attack)!$
 It is also possible that the RSA host key has just been changed.$
 The fingerprint for the RSA key sent by the remote host is$
 g8:ac:7d:8d:df:32:f6:3a:f5:96:31:9a:13:27:eb:38.$
 Please contact your system administrator.$
 Add correct host key in /u/thiagu/.ssh/known_hosts to get rid of this message.$
 Offending key in /u/thiagu/.ssh/known_hosts:5$
 RSA host key for host1 has changed and you have requested strict$
 checking.$
 Host key verification failed.$

Solution:
Entries in known hosts must have outdated. Remove corresponding entry for the machine in /user_home_dir/.ssh/known_hosts  and add a updated one.

Characters of HTML file served by Apache are showing wrongly

Problem
Characters of  HTML file served by Apache are showing wrongly. Some characters like spaces or characters  are shown like symbols.

Solution:
Change character set of  apache by editing httpd.conf file 
edit  /etc/httpd/conf/httpd.conf and  change the value for the variable AddDefaultCharset
ex :-
AddDefaultCharset en_US.iso88591

Restart apache after editing httpd.conf. (To restart apache run "service httpd restart")



Similarly
Default character set of a system will be defined in a system variable called "LANG"
check your system's  value with
"echo $LANG"
change it according to your requirement
example-
 export LANG=en_US.iso88591


To see the list of possible character set in your system run
$> localedef --list-archive 
 

To name a few ,
en_US.iso88591
en_US.iso885915
en_GB.iso88591
en_GB.iso885915



Nov 4, 2009

Linux - Add newline in echo statements

To include newline in echo add '-e'

echo -e "Thiagu\nMohan"