/etc/resolv.confcontains a nameserver that is alive (as reported by thepingcommand)hostornslookupis able to resolvegoogle.com
$ host google.com google.com has address 74.125.228.3 google.com has address 74.125.228.4 ... $ nslookup google.com ... Non-authorative answer: Name: google.com Address: 74.125.228.0 Name: google.com Address: 74.125.228.1 ..pingortelnetis not able to resolvegoogle.com
$ ping google.com ping: unknown host google.com $ telnet google.com google.com: node name or service name not knownFix Solution:This tells the Solaris Naming Service that hosts should be looked up first in the local file (i.e.Your/etc/nsswitch.confshould have an entry like this:hosts: files dns/etc/hosts) and then in DNS. You can of course also only have "dns" here but people will normally want it so that/etc/hostscan override what is in DNS.
You may now have to restart the naming service daemon:
$svcadm restart /system/name-service-cache
Thursday, August 13, 2015
Solaris 10 - `host` and `nslookup` resolves hostnames while `ping` and `telnet` does not?
Solaris 10 - Configure a Physical Ethernet Interface After System Installation
-
On the system with the interfaces to be configured, assume the
Primary Administrator role or become superuser.
The Primary Administrator role includes the Primary Administrator profile. To create the role and assign the role to a user, see Chapter 2, Working With the Solaris Management Console (Tasks), in System Administration Guide: Basic Administration.
-
Determine which interfaces are currently installed on the system.
# dladm show-link
-
Configure and plumb each interface.
# ifconfig interface plumb up
For example, for qfe0 you would type:
# ifconfig qfe0 plumb up
Note: Interfaces that are explicitly configured with the ifconfig command do not persist across a reboot.
-
Assign an IPv4 address and netmask to the interface.
For example, for qfe0 you would type:
# ifconfig interface IPv4-address netmask+netmask
# ifconfig qfe0 192.168.84.3 netmask + 255.255.255.0
Note: You can specify an IPv4 address in either traditional IPv4 notation or CIDR notation.
-
Verify that the newly configured interfaces are plumbed and configured,
or “UP.”
Check the status line for each interface that is displayed. Ensure that the output contains an UP flag on the status line, for example:
# ifconfig -a
qfe0: flags=1000843 <UP,BROADCAST,RUNNING,MULTICAST,IPv4> mtu 1500 index 2
-
(Optional) To make the interface configuration persist across
reboots, perform the following steps:
-
Create an /etc/hostname.interface file
for each interface to be configured.
For example, to add a qfe0 interface, you would create the following file:
# vi /etc/hostname.qfe0
Note – If you create alternate hostname files for the same interface, the alternate files must also follow the naming format hostname.[0–9]*, such as hostname.qfe0.a123. Names such as hostname.qfe0.bak or hostname.qfe0.old are invalid and will be ignored by scripts during system boot.
Note, too, that a given interface must have only one corresponding hostname file. If you create an alternate hostname file for an interface with a valid filename, such as /etc/hostname.qfe and /etc/hostname.qfe.a123, the boot scripts will attempt to configure by referencing the contents of both hostname files and would therefore generate errors. To prevent these errors, provide an invalid file name to the hostname file that you do not want to use in a given configuration.
-
Edit the /etc/hostname.interface file.
At a minimum, add the IPv4 address of the interface to the file. You can use traditional IPv4 notation or CIDR notation to specify the IP address of the interface. You can also add a netmask and other configuration information to the file.
Note – To add an IPv6 address to an interface, refer to Modifying an IPv6 Interface Configuration for Hosts and Servers
-
For Solaris 10 11/06 and earlier releases of Oracle Solaris 10,
add entries for the new interfaces into the /etc/inet/ipnodes file.
-
Add entries for the new interfaces into the /etc/inet/hosts file.
-
Perform a reconfiguration boot.
# reboot -- -r
-
Verify that the interface you created in the /etc/hostname.interface file has been configured.
For examples, refer to Example 6–2.
# ifconfig -a
-
Create an /etc/hostname.interface file
for each interface to be configured.
Example 6–2 Adding Persistent Interface Configurations
The example shows how to configure the interfaces qfe0 and qfe1 to a host. These interfaces remain persistent across reboots.
# dladm show-link eri0 type: legacy mtu: 1500 device: eri0 qfe0 type: legacy mtu: 1500 device: qfe0 qfe1 type: legacy mtu: 1500 device: qfe1 qfe2 type: legacy mtu: 1500 device: qfe2 qfe3 type: legacy mtu: 1500 device: qfe3 bge0 type: non-vlan mtu: 1500 device: bge0 # vi /etc/hostname.qfe0 192.168.84.3 netmask 255.255.255.0 # vi /etc/hostname.qfe1 192.168.84.72 netmask 255.255.255.0 # vi /etc/inet/hosts # Internet host table # 127.0.0.1 localhost 10.0.0.14 myhost 192.168.84.3 interface-2 192.168.84.72 interface-3 For Solaris 10 11/06 and earlier releases:# vi /etc/inet/ipnodes 10.0.0.14 myhost 192.168.84.3 interface-2 192.168.84.72 interface-3 |
At this point, you would reboot the system.
# reboot -- -r |
After the system boots, you would then verify the interface configuration.
ifconfig -a
# ifconfig -a lo0: flags=1000849 <UP,LOOPBACK,RUNNING,MULTICAST,IPv4> mtu
8232 index 1
inet 127.0.0.1 netmask ff000000
eri0: flags=1000843<UP,BROADCAST,RUNNING,MULTICAST,IPv4> mtu 1500 index 2
inet 10.0.0.14netmask ff000000 broadcast 10.255.255.255
ether 8:0:20:c1:8b:c3
qfe0:flags=1000843 <UP,BROADCAST,RUNNING,MULTICAST,IPv4> mtu 1500 index 3
inet 192.168.84.3 netmask ffffff00 broadcast 192.255.255.255
ether 8:0:20:c8:f4:1d
qfe1: flags=1000843 <UP,BROADCAST,RUNNING,MULTICAST,IPv4>mtu 1500 index 4
inet 192.168.84.72 netmask ffffff00 broadcast 10.255.255.255
ether 8:0:20:c8:f4:1e
|
Tuesday, August 11, 2015
Install Firefox 39 on CentOS, Ubuntu & Other Linux Systems
Remove Existing Version’s
First remove any existing version of Firefox from your system if installed using rpm. Redhat based system use following command.# yum remove firefox
Downloading Latest Firefox Archive
Download the latest Firefox archive from here (32 bit) and here (64 bit). At the time of last update of this article Firefox 39 is the latest version available. Download Firefox 39 source code as per your system architecture using one of following commands.32-Bit Systems
# cd /usr/local # wget http://ftp.mozilla.org/pub/mozilla.org/firefox/releases/39.0/linux-i686/en-US/firefox-39.0.tar.bz2
64-Bit Systems
# cd /usr/local # wget http://ftp.mozilla.org/pub/mozilla.org/firefox/releases/39.0/linux-x86_64/en-US/firefox-39.0.tar.bz2
Extract Archive on System
After downloading latest version of Firefox archive on your system, let’s extract is using following command.# tar xvjf firefox-39.0.tar.bz2
Configure Firefox
Firefox source is completely pre compiled and we don’t have to do anything to make it running on system. We just need to create a soft-link of Firefox binary file to systems bin directory to make it accessible from anywhere in system.# ln -s /usr/local/firefox/firefox /usr/bin/firefox
Now start Firefox using following command from Linux terminal.
# firefox &
Wednesday, August 5, 2015
TAR Commands,examples for Linux
1. Create tar Archive File
The below example command will create a tar archive file tecmint-14-09-12.tar for a directory /home/tecmint in current working directory. See the example command in action.# tar -cvf tecmint-14-09-12.tar /home/tecmint/ /home/tecmint/ /home/tecmint/cleanfiles.sh /home/tecmint/openvpn-2.1.4.tar.gz /home/tecmint/tecmint-14-09-12.tar /home/tecmint/phpmyadmin-2.11.11.3-1.el5.rf.noarch.rpm /home/tecmint/rpmforge-release-0.5.2-2.el5.rf.i386.rpmLet’s discuss the each option we have used in the above command for creating tar archive file.
- c – Creates a new .tar archive file.
- v – Verbosely show the .tar file progress.
- f – File name type of the archive file.
2. Create tar.gz Archive File
To create a compressed gzip archive file we use the option as z. For example the below command will create a compressed MyImages-14-09-12.tar.gz file for the directory /home/MyImages. (Note : tar.gz and tgz both are similar).# tar cvzf MyImages-14-09-12.tar.gz /home/MyImages OR # tar cvzf MyImages-14-09-12.tgz /home/MyImages /home/MyImages/ /home/MyImages/Sara-Khan-and-model-Priyanka-Shah.jpg /home/MyImages/RobertKristenviolent101201.jpg /home/MyImages/Justintimerlake101125.jpg /home/MyImages/Mileyphoto101203.jpg /home/MyImages/JenniferRobert101130.jpg /home/MyImages/katrinabarbiedoll231110.jpg /home/MyImages/the-japanese-wife-press-conference.jpg /home/MyImages/ReesewitherspoonCIA101202.jpg /home/MyImages/yanaguptabaresf231110.jpg
3. Create tar.bz2 Archive File
The bz2 feature compress and create archive file less than the size of the gzip. The bz2 compression takes more time to compress and decompress files as compared to gzip which takes less time. To create highly compressed tar file we use option as j. The following example of command will create a Phpfiles-org.tar.bz2 file for a directory /home/php. (Note: tar.bz2 and tbz is similar as tb2).# tar cvfj Phpfiles-org.tar.bz2 /home/php OR # tar cvfj Phpfiles-org.tar.tbz /home/php OR # tar cvfj Phpfiles-org.tar.tb2 /home/php /home/php/ /home/php/iframe_ew.php /home/php/videos_all.php /home/php/rss.php /home/php/index.php /home/php/vendor.php /home/php/video_title.php /home/php/report.php /home/php/object.html /home/php/video.php
4. Untar tar Archive File
To untar or extract a tar file, just issue following command using option x (extract). For example the below command will untar the file public_html-14-09-12.tar in present working directory. If you want untar in a different directory then use option as -C (specified directory).## Untar files in Current Directory ## # tar -xvf public_html-14-09-12.tar ## Untar files in specified Directory ## # tar -xvf public_html-14-09-12.tar -C /home/public_html/videos/ /home/public_html/videos/ /home/public_html/videos/views.php /home/public_html/videos/index.php /home/public_html/videos/logout.php /home/public_html/videos/all_categories.php /home/public_html/videos/feeds.xml
5. Uncompress tar.gz Archive File
To Uncompress tar.gz archive file, just run following command. If would like to untar in different directory just use option -C and the path of the directory, like we shown in the above example.# tar -xvf thumbnails-14-09-12.tar.gz /home/public_html/videos/thumbnails/ /home/public_html/videos/thumbnails/katdeepika231110.jpg /home/public_html/videos/thumbnails/katrinabarbiedoll231110.jpg /home/public_html/videos/thumbnails/onceuponatime101125.jpg /home/public_html/videos/thumbnails/playbutton.png /home/public_html/videos/thumbnails/ReesewitherspoonCIA101202.jpg /home/public_html/videos/thumbnails/snagItNarration.jpg /home/public_html/videos/thumbnails/Minissha-Lamba.jpg /home/public_html/videos/thumbnails/Lindsaydance101201.jpg /home/public_html/videos/thumbnails/Mileyphoto101203.jpg
6. Uncompress tar.bz2 Archive File
To Uncompress highly compressed tar.bz2 file, just use the following command. The below example command will untar all the .flv files from the archive file.# tar -xvf videos-14-09-12.tar.bz2 /home/public_html/videos/flv/katrinabarbiedoll231110.flv /home/public_html/videos/flv/BrookmuellerCIA101125.flv /home/public_html/videos/flv/dollybackinbb4101125.flv /home/public_html/videos/flv/JenniferRobert101130.flv /home/public_html/videos/flv/JustinAwardmovie101125.flv /home/public_html/videos/flv/Lakme-Fashion-Week.flv /home/public_html/videos/flv/Mileyphoto101203.flv /home/public_html/videos/flv/Minissha-Lamba.flv
7. List Content of tar Archive File
To list the content of tar archive file, just run the following command with option t (list content). The below command will list the content of uploadprogress.tar file.# tar -tvf uploadprogress.tar -rw-r--r-- chregu/staff 2276 2011-08-15 18:51:10 package2.xml -rw-r--r-- chregu/staff 7877 2011-08-15 18:51:10 uploadprogress/examples/index.php -rw-r--r-- chregu/staff 1685 2011-08-15 18:51:10 uploadprogress/examples/server.php -rw-r--r-- chregu/staff 1697 2011-08-15 18:51:10 uploadprogress/examples/info.php -rw-r--r-- chregu/staff 367 2011-08-15 18:51:10 uploadprogress/config.m4 -rw-r--r-- chregu/staff 303 2011-08-15 18:51:10 uploadprogress/config.w32 -rw-r--r-- chregu/staff 3563 2011-08-15 18:51:10 uploadprogress/php_uploadprogress.h -rw-r--r-- chregu/staff 15433 2011-08-15 18:51:10 uploadprogress/uploadprogress.c -rw-r--r-- chregu/staff 1433 2011-08-15 18:51:10 package.xml
8. List Content tar.gz Archive File
Use the following command to list the content of tar.gz file.# tar -tvf staging.tecmint.com.tar.gz -rw-r--r-- root/root 0 2012-08-30 04:03:57 staging.tecmint.com-access_log -rw-r--r-- root/root 587 2012-08-29 18:35:12 staging.tecmint.com-access_log.1 -rw-r--r-- root/root 156 2012-01-21 07:17:56 staging.tecmint.com-access_log.2 -rw-r--r-- root/root 156 2011-12-21 11:30:56 staging.tecmint.com-access_log.3 -rw-r--r-- root/root 156 2011-11-20 17:28:24 staging.tecmint.com-access_log.4 -rw-r--r-- root/root 0 2012-08-30 04:03:57 staging.tecmint.com-error_log -rw-r--r-- root/root 3981 2012-08-29 18:35:12 staging.tecmint.com-error_log.1 -rw-r--r-- root/root 211 2012-01-21 07:17:56 staging.tecmint.com-error_log.2 -rw-r--r-- root/root 211 2011-12-21 11:30:56 staging.tecmint.com-error_log.3 -rw-r--r-- root/root 211 2011-11-20 17:28:24 staging.tecmint.com-error_log.4
9. List Content tar.bz2 Archive File
To list the content of tar.bz2 file, issue the following command.# tar -tvf Phpfiles-org.tar.bz2 drwxr-xr-x root/root 0 2012-09-15 03:06:08 /home/php/ -rw-r--r-- root/root 1751 2012-09-15 03:06:08 /home/php/iframe_ew.php -rw-r--r-- root/root 11220 2012-09-15 03:06:08 /home/php/videos_all.php -rw-r--r-- root/root 2152 2012-09-15 03:06:08 /home/php/rss.php -rw-r--r-- root/root 3021 2012-09-15 03:06:08 /home/php/index.php -rw-r--r-- root/root 2554 2012-09-15 03:06:08 /home/php/vendor.php -rw-r--r-- root/root 406 2012-09-15 03:06:08 /home/php/video_title.php -rw-r--r-- root/root 4116 2012-09-15 03:06:08 /home/php/report.php -rw-r--r-- root/root 1273 2012-09-15 03:06:08 /home/php/object.html
10. Untar Single file from tar File
To extract a single file called cleanfiles.sh from cleanfiles.sh.tar use the following command.# tar -xvf cleanfiles.sh.tar cleanfiles.sh OR # tar --extract --file=cleanfiles.sh.tar cleanfiles.sh cleanfiles.sh
11. Untar Single file from tar.gz File
To extract a single file tecmintbackup.xml from tecmintbackup.tar.gz archive file, use the command as follows.# tar -zxvf tecmintbackup.tar.gz tecmintbackup.xml OR # tar --extract --file=tecmintbackup.tar.gz tecmintbackup.xml tecmintbackup.xml
12. Untar Single file from tar.bz2 File
To extract a single file called index.php from the file Phpfiles-org.tar.bz2 use the following option.# tar -jxvf Phpfiles-org.tar.bz2 home/php/index.php OR # tar --extract --file=Phpfiles-org.tar.bz2 /home/php/index.php /home/php/index.php
13. Untar Multiple files from tar, tar.gz and tar.bz2 File
To extract or untar multiple files from the tar, tar.gz and tar.bz2 archive file. For example the below command will extract “file 1” “file 2” from the archive files.# tar -xvf tecmint-14-09-12.tar "file 1" "file 2" # tar -zxvf MyImages-14-09-12.tar.gz "file 1" "file 2" # tar -jxvf Phpfiles-org.tar.bz2 "file 1" "file 2"
14. Extract Group of Files using Wildcard
To extract a group of files we use wildcard based extracting. For example, to extract a group of all files whose pattern begins with .php from a tar, tar.gz and tar.bz2 archive file.# tar -xvf Phpfiles-org.tar --wildcards '*.php' # tar -zxvf Phpfiles-org.tar.gz --wildcards '*.php' # tar -jxvf Phpfiles-org.tar.bz2 --wildcards '*.php' /home/php/iframe_ew.php /home/php/videos_all.php /home/php/rss.php /home/php/index.php /home/php/vendor.php /home/php/video_title.php /home/php/report.php /home/php/video.php
15. Add Files or Directories to tar Archive File
To add files or directories to existing tar archived file we use the option r (append). For example we add file xyz.txt and directory php to existing tecmint-14-09-12.tar archive file.# tar -rvf tecmint-14-09-12.tar xyz.txt # tar -rvf tecmint-14-09-12.tar php drwxr-xr-x root/root 0 2012-09-15 02:24:21 home/tecmint/ -rw-r--r-- root/root 15740615 2012-09-15 02:23:42 home/tecmint/cleanfiles.sh -rw-r--r-- root/root 863726 2012-09-15 02:23:41 home/tecmint/openvpn-2.1.4.tar.gz -rw-r--r-- root/root 21063680 2012-09-15 02:24:21 home/tecmint/tecmint-14-09-12.tar -rw-r--r-- root/root 4437600 2012-09-15 02:23:41 home/tecmint/phpmyadmin-2.11.11.3-1.el5.rf.noarch.rpm -rw-r--r-- root/root 12680 2012-09-15 02:23:41 home/tecmint/rpmforge-release-0.5.2-2.el5.rf.i386.rpm -rw-r--r-- root/root 0 2012-08-18 19:11:04 xyz.txt drwxr-xr-x root/root 0 2012-09-15 03:06:08 php/ -rw-r--r-- root/root 1751 2012-09-15 03:06:08 php/iframe_ew.php -rw-r--r-- root/root 11220 2012-09-15 03:06:08 php/videos_all.php -rw-r--r-- root/root 2152 2012-09-15 03:06:08 php/rss.php -rw-r--r-- root/root 3021 2012-09-15 03:06:08 php/index.php -rw-r--r-- root/root 2554 2012-09-15 03:06:08 php/vendor.php -rw-r--r-- root/root 406 2012-09-15 03:06:08 php/video_title.php
16. Add Files or Directories to tar.gz and tar.bz2 files
The tar command don’t have a option to add files or directories to a existing compressed tar.gz and tar.bz2 archive file. If we do try will get tbe following error.# tar -rvf MyImages-14-09-12.tar.gz xyz.txt # tar -rvf Phpfiles-org.tar.bz2 xyz.txt tar: This does not look like a tar archive tar: Skipping to next header xyz.txt tar: Error exit delayed from previous errors
17. How To Verify tar, tar.gz and tar.bz2 Archive File
To verfify any tar or compressed archived file we use option as W (verify). To do, just use the following examples of command. (Note : You cannot do verification on a compressed ( *.tar.gz, *.tar.bz2 ) archive file).# tar tvfW tecmint-14-09-12.tar tar: This does not look like a tar archive tar: Skipping to next header tar: Archive contains obsolescent base-64 headers tar: VERIFY FAILURE: 30740 invalid headers detected Verify -rw-r--r-- root/root 863726 2012-09-15 02:23:41 /home/tecmint/openvpn-2.1.4.tar.gz Verify -rw-r--r-- root/root 21063680 2012-09-15 02:24:21 /home/tecmint/tecmint-14-09-12.tar tar: /home/tecmint/tecmint-14-09-12.tar: Warning: Cannot stat: No such file or directory Verify -rw-r--r-- root/root 4437600 2012-09-15 02:23:41 home/tecmint/phpmyadmin-2.11.11.3-1.el5.rf.noarch.rpm tar: /home/tecmint/phpmyadmin-2.11.11.3-1.el5.rf.noarch.rpm: Warning: Cannot stat: No such file or directory Verify -rw-r--r-- root/root 12680 2012-09-15 02:23:41 home/tecmint/rpmforge-release-0.5.2-2.el5.rf.i386.rpm tar: /home/tecmint/rpmforge-release-0.5.2-2.el5.rf.i386.rpm: Warning: Cannot stat: No such file or directory Verify -rw-r--r-- root/root 0 2012-08-18 19:11:04 xyz.txt Verify drwxr-xr-x root/root 0 2012-09-15 03:06:08 php/
18. Check the Size of the tar, tar.gz and tar.bz2 Archive File
To check the size of any tar, tar.gz and tar.bz2 archive file, use the following command. For example the below command will display the size of archvie file in Kilobytes (KB).# tar -czf - tecmint-14-09-12.tar | wc -c 12820480 # tar -czf - MyImages-14-09-12.tar.gz | wc -c 112640 # tar -czf - Phpfiles-org.tar.bz2 | wc -c 20480
Monday, August 3, 2015
RPM Commands, examples for Linux
There are five basic modes for RPM command
- Install : It is used to install any RPM package.
- Remove : It is used to erase, remove or un-install any RPM package.
- Upgrade : It is used to update the existing RPM package.
- Verify : It is used to query about different RPM packages.
- Query : It is used for the verification of any RPM package.
Where to find RPM packages
Below is the list of rpm sites, where you can find and download all RPM packages.1. How to Check an RPM Signature Package
Always check the PGP signature of packages before installing them on your Linux systems and make sure its integrity and origin is OK. Use the following command with –checksig (check signature) option to check the signature of a package called pidgin.[root@tecmint]# rpm --checksig pidgin-2.7.9-5.el6.2.i686.rpm pidgin-2.7.9-5.el6.2.i686.rpm: rsa sha1 (md5) pgp md5 OK
2. How to Install an RPM Package
For installing an rpm software package, use the following command with -i option. For example, to install an rpm package called pidgin-2.7.9-5.el6.2.i686.rpm.[root@tecmint]# rpm -ivh pidgin-2.7.9-5.el6.2.i686.rpm Preparing... ########################################### [100%] 1:pidgin ########################################### [100%]
RPM command and options
- -i : install a package
- -v : verbose for a nicer display
- -h: print hash marks as the package archive is unpacked.
3. How to check dependencies of RPM Package before Installing
Let’s say you would like to do a dependency check before installing or upgrading a package. For example, use the following command to check the dependencies of BitTorrent-5.2.2-1-Python2.4.noarch.rpm package. It will display the list of dependencies of package.[root@tecmint]# rpm -qpR BitTorrent-5.2.2-1-Python2.4.noarch.rpm /usr/bin/python2.4 python >= 2.3 python(abi) = 2.4 python-crypto >= 2.0 python-psyco python-twisted >= 2.0 python-zopeinterface rpmlib(CompressedFileNames) = 2.6
RPM command and options
- -q : Query a package
- -p : List capabilities this package provides.
- -R: List capabilities on which this package depends..
4. How to Install a RPM Package Without Dependencies
If you know that all needed packages are already installed and RPM is just being stupid, you can ignore those dependencies by using the option –nodeps (no dependencies check) before installing the package.[root@tecmint]# rpm -ivh --nodeps BitTorrent-5.2.2-1-Python2.4.noarch.rpm Preparing... ########################################### [100%] 1:BitTorrent ########################################### [100%] The above command forcefully install
rpm package by ignoring dependencies errors, but if those dependency files are missing, then the program will not work at all, until you install them.
5. How to check an Installed RPM Package
Using -q option with package name, will show whether an rpm installed or not.[root@tecmint]# rpm -q BitTorrent BitTorrent-5.2.2-1.noarch
6. How to List all files of an installed RPM package
To view all the files of an installed rpm packages, use the -ql (query list) with rpm command.[root@tecmint]# rpm -ql BitTorrent /usr/bin/bittorrent /usr/bin/bittorrent-console /usr/bin/bittorrent-curses /usr/bin/bittorrent-tracker /usr/bin/changetracker-console /usr/bin/launchmany-console /usr/bin/launchmany-curses /usr/bin/maketorrent /usr/bin/maketorrent-console /usr/bin/torrentinfo-console
7. How to List Recently Installed RPM Packages
Use the following rpm command with -qa (query all) option, will list all the recently installed rpm packages.[root@tecmint]# rpm -qa --last BitTorrent-5.2.2-1.noarch Tue 04 Dec 2012 05:14:06 PM BDT pidgin-2.7.9-5.el6.2.i686 Tue 04 Dec 2012 05:13:51 PM BDT cyrus-sasl-devel-2.1.23-13.el6_3.1.i686 Tue 04 Dec 2012 04:43:06 PM BDT cyrus-sasl-2.1.23-13.el6_3.1.i686 Tue 04 Dec 2012 04:43:05 PM BDT cyrus-sasl-md5-2.1.23-13.el6_3.1.i686 Tue 04 Dec 2012 04:43:04 PM BDT cyrus-sasl-plain-2.1.23-13.el6_3.1.i686 Tue 04 Dec 2012 04:43:03 PM BDT
8. How to List All Installed RPM Packages
Type the following command to print the all the names of installed packages on your Linux system.[root@tecmint]# rpm -qa initscripts-9.03.31-2.el6.centos.i686 polkit-desktop-policy-0.96-2.el6_0.1.noarch thunderbird-17.0-1.el6.remi.i686
9. How to Upgrade a RPM Package
If we want to upgrade any RPM package “–U” (upgrade) option will be used. One of the major advantages of using this option is that it will not only upgrade the latest version of any package, but it will also maintain the backup of the older package so that in case if the newer upgraded package does not run the previously installed package can be used again.[root@tecmint]# rpm -Uvh nx-3.5.0-2.el6.centos.i686.rpm Preparing... ########################################### [100%] 1:nx ########################################### [100%]
10. How to Remove a RPM Package
To un-install an RPM package, for example we use the package name nx, not the original package name nx-3.5.0-2.el6.centos.i686.rpm. The -e (erase) option is used to remove package.[root@tecmint]# rpm -evv nx
11. How to Remove an RPM Package Without Dependencies
The –nodeps (Do not check dependencies) option forcefully remove the rpm package from the system. But keep in mind removing particular package may break other working applications.[root@tecmint]# rpm -ev --nodeps vsftpd
12. How to Query a file that belongs which RPM Package
Let’s say, you have list of files and you would like to find out which package belongs to these files. For example, the following command with -qf (query file) option will show you a file /usr/bin/htpasswd is own by package httpd-tools-2.2.15-15.el6.centos.1.i686.[root@tecmint]# rpm -qf /usr/bin/htpasswd httpd-tools-2.2.15-15.el6.centos.1.i686
13. How to Query a Information of Installed RPM Package
Let’s say you have installed an rpm package and want to know the information about the package. The following -qi (query info) option will print the available information of the installed package.[root@tecmint]# rpm -qi vsftpd Name : vsftpd Relocations: (not relocatable) Version : 2.2.2 Vendor: CentOS Release : 11.el6 Build Date: Fri 22 Jun 2012 01:54:24 PM BDT Install Date: Mon 17 Sep 2012 07:55:28 PM BDT Build Host: c6b8.bsys.dev.centos.org Group : System Environment/Daemons Source RPM: vsftpd-2.2.2-11.el6.src.rpm Size : 351932 License: GPLv2 with exceptions Signature : RSA/SHA1, Mon 25 Jun 2012 04:07:34 AM BDT, Key ID 0946fca2c105b9de Packager : CentOS BuildSystem <http://bugs.centos.org> URL : http://vsftpd.beasts.org/ Summary : Very Secure Ftp Daemon Description : vsftpd is a Very Secure FTP daemon. It was written completely from scratch.
14. Get the Information of RPM Package Before Installing
You have download a package from the internet and want to know the information of a package before installing. For example, the following option -qip (query info package) will print the information of a package sqlbuddy.[root@tecmint]# rpm -qip sqlbuddy-1.3.3-1.noarch.rpm Name : sqlbuddy Relocations: (not relocatable) Version : 1.3.3 Vendor: (none) Release : 1 Build Date: Wed 02 Nov 2011 11:01:21 PM BDT Install Date: (not installed) Build Host: rpm.bar.baz Group : Applications/Internet Source RPM: sqlbuddy-1.3.3-1.src.rpm Size : 1155804 License: MIT Signature : (none) Packager : Erik M Jacobs URL : http://www.sqlbuddy.com/ Summary : SQL Buddy รข Web based MySQL administration Description : SQLBuddy is a PHP script that allows for web-based MySQL administration.
15. How to Query documentation of Installed RPM Package
To get the list of available documentation of an installed package, use the following command with option -qdf (query document file) will display the manual pages related to vmstat package.[root@tecmint]# rpm -qdf /usr/bin/vmstat /usr/share/doc/procps-3.2.8/BUGS /usr/share/doc/procps-3.2.8/COPYING /usr/share/doc/procps-3.2.8/COPYING.LIB /usr/share/doc/procps-3.2.8/FAQ /usr/share/doc/procps-3.2.8/NEWS /usr/share/doc/procps-3.2.8/TODO
16. How to Verify a RPM Package
Verifying a package compares information of installed files of the package against the rpm database. The -Vp (verify package) is used to verify a package.[root@tecmint downloads]# rpm -Vp sqlbuddy-1.3.3-1.noarch.rpm S.5....T. c /etc/httpd/conf.d/sqlbuddy.conf
17. How to Verify all RPM Packages
Type the following command to verify all the installed rpm packages.[root@tecmint]# rpm -Va S.5....T. c /etc/rc.d/rc.local .......T. c /etc/dnsmasq.conf .......T. /etc/ld.so.conf.d/kernel-2.6.32-279.5.2.el6.i686.conf S.5....T. c /etc/yum.conf S.5....T. c /etc/yum.repos.d/epel.repo
18. How to Import an RPM GPG key
To verify RHEL/CentOS/Fedora packages, you must import the GPG key. To do so, execute the following command. It will import CentOS 6 GPG key.[root@tecmint]# rpm --import /etc/pki/rpm-gpg/RPM-GPG-KEY-CentOS-6
19. How to List all Imported RPM GPG keys
To print all the imported GPG keys in your system, use the following command.[root@tecmint]# rpm -qa gpg-pubkey* gpg-pubkey-0608b895-4bd22942 gpg-pubkey-7fac5991-4615767f gpg-pubkey-0f2672c8-4cd950ee gpg-pubkey-c105b9de-4e0fd3a3 gpg-pubkey-00f97f56-467e318a gpg-pubkey-6b8d79e6-3f49313d gpg-pubkey-849c449f-4cb9df30
20. How To rebuild Corrupted RPM Database
Sometimes rpm database gets corrupted and stops all the functionality of rpm and other applications on the system. So, at the time we need to rebuild the rpm database and restore it with the help of following command.[root@tecmint]# cd /var/lib [root@tecmint]# rm __db* [root@tecmint]# rpm --rebuilddb [root@tecmint]# rpmdb_verify Packages
Thursday, November 7, 2013
RPM command cheat sheet for RH Linux
rpm is a powerful Package Manager for Red Hat, Suse and Fedora Linux.
It can be used to build, install, query, verify, update, and
remove/erase individual software packages. A Package consists of an
archive of files, and package information, including name, version, and
description:
{package} - Replace with actual package name
RPM is nothing but a a package management system. To install an rpm file, open a terminal and then type the following command:
Note: you can download the package in rpm format from the official project web pages or public ftp servers.
If you are upgrading from an earlier version of the software package, use upgrade mode command as described above.
Type the following command:
To find list of all install packages, enter:
Sample outputs:
To remove samba-client-3.0.33-3.29.el5_6.2, enter:
| Syntax | Description | Example(s) |
| rpm -ivh {rpm-file} | Install the package | rpm -ivh mozilla-mail-1.7.5-17.i586.rpm rpm -ivh --test mozilla-mail-1.7.5-17.i586.rpm |
| rpm -Uvh {rpm-file} | Upgrade package | rpm -Uvh mozilla-mail-1.7.6-12.i586.rpm rpm -Uvh --test mozilla-mail-1.7.6-12.i586.rpm |
| rpm -ev {package} | Erase/remove/ an installed package | rpm -ev mozilla-mail |
| rpm -ev --nodeps {package} | Erase/remove/ an installed package without checking for dependencies | rpm -ev --nodeps mozilla-mail |
| rpm -qa | Display list all installed packages | rpm -qa rpm -qa | less |
| rpm -qi {package} | Display installed information along with package version and short description | rpm -qi mozilla-mail |
| rpm -qf {/path/to/file} | Find out what package a file belongs to i.e. find what package owns the file | rpm -qf /etc/passwd rpm -qf /bin/bash |
| rpm -qc {pacakge-name} | Display list of configuration file(s) for a package | rpm -qc httpd |
| rpm -qcf {/path/to/file} | Display list of configuration files for a command | rpm -qcf /usr/X11R6/bin/xeyes |
| rpm -qa --last | Display list of all recently installed RPMs | rpm -qa --last rpm -qa --last | less |
| rpm -qpR {.rpm-file} rpm -qR {package} |
Find out what dependencies a rpm file has | rpm -qpR mediawiki-1.4rc1-4.i586.rpm rpm -qR bash |
RPM is nothing but a a package management system. To install an rpm file, open a terminal and then type the following command:
rpm -ivh .rpm.file-namePlease note that you need to log in as root, or use the su command to change to the root user to install the software using rpm command:
$ su -Install RPM File
To install an rpm file called awstats.i386.rpm, enter:# rpm -ivh awstats.i386.rpm Note: you can download the package in rpm format from the official project web pages or public ftp servers.
Upgrade RPM File
Type the following command:# rpm -Uvh awstats.i386.rpm If you are upgrading from an earlier version of the software package, use upgrade mode command as described above.
Erase (Delete) RPM File (package)
Type the following command:# rpm -ev packagenameTo find list of all install packages, enter:
# rpm -qa
# rpm -qa | less
# rpm -qa | grep somethingSample outputs:
comps-extras-11.1-1.1 libattr-2.4.32-1.1 libidn-0.6.5-1.1 grep-2.5.1-55.el5 libxslt-1.1.17-2.el5_2.2 perl-Digest-SHA1-2.11-1.2.1 time-1.7-27.2.2 libdaemon-0.10-5.el5 .... ..... .. mysql-server-5.0.77-4.el5_5.5 mysql-devel-5.0.77-4.el5_5.5 samba-client-3.0.33-3.29.el5_6.2 pcre-6.6-6.el5_6.1 yum-rhn-plugin-0.5.4-17.el5_6.1 libtiff-3.8.2-7.el5_6.7 nash-5.1.19.6-68.el5_6.1 quota-3.13-5.el5 xorg-x11-server-Xorg-1.1.1-48.76.el5_6.4 xorg-x11-server-Xnest-1.1.1-48.76.el5_6.4
To remove samba-client-3.0.33-3.29.el5_6.2, enter:
# rpm -ev samba-client-3.0.33-3.29.el5_6.2
Tuesday, October 22, 2013
CHMOD Linux Commands
Purpose
Syntax
To Change File Modes Symbolically
chmod [ -R ] [ -h ] [ -f ] [ [ u ] [ g ] [ o ] | [ a ] ] { { - | + | = } [ r ] [ w ] [ x ] [ X ] [ s ] [ t ] } { File ... | Directory ... }To Change File Modes Numerically
chmod [ -R ] [ -h ] [ -f ] PermissionCode { File ... | Directory ... }Description
The chmod command modifies the
mode bits and the extended access control lists (ACLs) of the specified files
or directories. The mode can be defined symbolically or numerically (absolute
mode).
When a symbolic link is encountered and you have not
specified the -h flag, the chmod command
changes the mode of the file or directory pointed to by the link and not the
mode of the link itself. If you specify the -h flag,
the chmod command prevents this mode change.
If you specify both the -h flag
and the -R flag, the chmod command
descends the specified directories recursively, and when a symbolic link is
encountered, the mode of the file or directory pointed to by the link is not
changed.
Flags
Symbolic Mode
To specify a mode in symbolic form, you must specify
three sets of flags.
Note: Do not separate flags with spaces.
The first set of flags specifies who is granted or
denied the specified permissions, as follows:
The second set of flags specifies whether the permissions
are to be removed, applied, or set:
The third set of flags specifies the permissions that
are to be removed, applied, or set:
Numeric or Absolute Mode
The chmod command also permits
you to use octal notation for the mode. The numeric mode is the sum of one
or more of the following values:
Notes:
- Specifying the mode numerically disables any extended ACLs. Refer to "Access control Lists" in Operating system and device management for more information.
- Changing group access permissions symbolically also affects the AIXC ACL entries. The group entries in the ACL that are equal to the owning group of the file are denied any permission that is removed from the mode. Refer to "Access control Lists" in Operating system and device management for more information.
- You can specify multiple symbolic modes separated with commas. Operations are performed in the order they appear from left to right.
- You must specify the mode symbolically or use an explicit 4-character octal with a leading zero (for example, 0755) when removing the set-group-ID-on-execution permission from directories.
- For a non-AIXC ACL associated file system object, any request (either symbolically or numerically) that results in a operation to change the base permissions bits (rwxrwxrwx) in mode bits results in replacement of the existing ACL with just the mode bits.
Security
Access Control: This program should be installed as
a normal user program in the Trusted Computing Base.
Only the owner of the file or the root user can change
the mode of a file.
Exit Status
This command returns the following exit values:
| 0 | The command executed successfully and all requested changes were made. |
| >0 | An error occurred. |
Examples
- To add a type of permission to several files:
chmod g+w chap1 chap2
This adds write permission for group members to the files chap1 and chap2. - To make several permission changes at once:
chmod go-w+x mydir
This denies group members and others the permission to create or delete files in mydir (go-w) and allows group members and others to search mydir or use it in a path name (go+x). This is equivalent to the command sequence:chmod g-w mydir chmod o-w mydir chmod g+x mydir chmod o+x mydir
- To permit only the owner to use a shell procedure
as a command:
chmod u=rwx,go= cmd
This gives read, write, and execute permission to the user who owns the file (u=rwx). It also denies the group and others the permission to access cmd in any way (go=).If you have permission to execute the cmd shell command file, then you can run it by entering:cmd
Note: Depending on the PATH shell variable, you may need to specify the full path to the cmd file.
- To use Set-ID Modes:
chmod ug+s cmd
When the cmd command is executed, the effective user and group IDs are set to those that own the cmd file. Only the effective IDs associated with the child process that runs the cmd command are changed. The effective IDs of the shell session remain unchanged.This feature allows you to permit access to restricted files. Suppose that the cmd program has the Set-User-ID Mode enabled and is owned by a user called dbms. The user dbms is not actually a person, but might be associated with a database management system. The user betty does not have permission to access any of dbms's data files. However, she does have permission to execute the cmd command. When she does so, her effective user ID is temporarily changed to dbms, so that the cmd program can access the data files owned by the user dbms.This way the user betty can use the cmd command to access the data files, but she cannot accidentally damage them with the standard shell commands. - To use the absolute mode form of the chmod command:
chmod 644 text
This sets read and write permission for the owner, and it sets read-only mode for the group and others. This also removes all extended ACLs that might be associated with the file. - To recursively descend directories and change
file and directory permissions given the tree structure:
./dir1/dir2/file1./dir1/dir2/file2
./dir1/file1
enter this command sequence:chmod -R 777 f*
which will change permissions on ./dir1/file1.But given the tree structure of:./dir1/fdir2/file1./dir1/fdir2/file2
./dir1/file3
the command sequence:chmod -R 777 f*
will change permissions on:./dir1/fdir2./dir1/fdir2/file1
./dir1/fdir2/file2
./dir1/file3
Subscribe to:
Posts (Atom)