You can remove dependencies using yum-plugin-remove-with-leaves plug-in.
To install:
# yum install yum-plugin-remove-with-leaves
To use:
# yum remove --remove-leaves <package-name>
That's all folks :)
Linux is for everybody. Lets enjoy it.
You can remove dependencies using yum-plugin-remove-with-leaves plug-in.
To install:
# yum install yum-plugin-remove-with-leaves
# yum remove --remove-leaves <package-name>
This feature is useful if for example we want to delete a few lines or characters but we are too lazy to count the lines or characters to use dd or dw command. We can set up to 26 marker using lowercase a-z as the marker's name. The main usage of marker is to mark any location in file.
How to use (we put 'a' as the marker's name):
ma - mark current cursor position as marker named 'a'
`a (backquote a) - move to character marked as 'a'
'a (quote a) - move to first non blank character (line) containing marker 'a'
`` (backquote backquote) - move to last operated marker or toggles with last cursor position, if no marker is set, cursor moves to beginning of file (BOF)
'' (quote quote) - move to beginning og line (BOL) operated marker or toggles with BOL of last cursor position, if no marker is set, cursor moves to BOF
Example on using marker:
If you want to indent 5 lines starting from current line: majjjjj>'a
If you want to delete five words using marker: mawwwwwmb`ad`b
That's all friends :)
Starting from fedora 12, I found out that I cannot edit my main menu anymore. This is kind of frustrating since I installed many custom applications, and I would like it to be easily accessible from the main menu. After searching around, i found out that one package is not included in fedora 12 livecd. The package is called alacarte.
$ rpm -qi alacarte
Name : alacarte Relocations: (not relocatable)
Version : 0.12.4 Vendor: Fedora Project
Release : 1.fc12 Build Date: Tue 22 Sep 2009 08:41:26 AM MYT
Install Date: Sat 13 Nov 2010 07:17:32 AM MYT Build Host: xenbuilder4.fedora.phx.redhat.com
Group : Applications/System Source RPM: alacarte-0.12.4-1.fc12.src.rpm
Size : 367423 License: LGPLv2+
Signature : RSA/8, Thu 01 Oct 2009 03:42:28 AM MYT, Key ID 9d1cc34857bbccba
Packager : Fedora Project
URL : http://www.gnome.org
Summary : Menu editor for the GNOME desktop
Description :
Alacarte is a graphical menu editor that lets you edit, add, and delete
menu entries. It follows the freedesktop.org menu specification and
should work with any desktop environment that uses this specification.
# yum install alacarte -y
That's all folks
By default, the time and date in domU is following dom0. To reset that, below are just what you have to do to decouple the domU's date from dom0
On dom0:
Append xen.independent_wallclock=1 to /etc/sysctl.conf
# echo "xen.independent_wallclock=1" >> /etc/sysctl.conf
Activate the change# sysctl -p
Append extra="clocksource=jiffies" to the domU's configuration file.# echo "extra=\"clocksource=jiffies\"" >> /etc/xen/<domU's name>.cfg
# echo "xen.independent_wallclock=1" >> /etc/sysctl.conf
Activate the change# sysctl -p
Append jiffies to /sys/devices/system/clocksource/clocksource0/current_clocksource# echo "jiffies" >> /sys/devices/system/clocksource/clocksource0/current_clocksource
To create ssh tunnel is very easy. Let's say you want to use machine1.example.com as your ssh proxy, your username is foo and you choose port 8080 on your localhost to be your local proxy port. Type below command on your localhost:
$ ssh -D 8080 foo@machine1.example.com
Once connected, set your browser to use Socks5 proxy on port 8080 on your local machine. For firefox, the setting is "Tools -> Options -> Advanced -> Network -> Settings -> Manual proxy configuration" and follow below picture for the proxy setting. Just make sure to keep the ssh connection connected to reap the ssh proxy benefits :)If you are a windows user, and you use cygwin, there is a problem with man page. The search function is a bit weird, where it cannot find something like "-D" in ssh man page. To overcome this, you have to set the LANG environment variable to c. To do this, just add export LANG=c to your .bashrc:
$ echo "export LANG=c" >> .bashrc
If you are creating new user in your machine, and you would like them to change password the first time they login, using command chage is the way. Let's say our user is foo.
# chage -d 0 foo
where -d is for lastday. When we set it to 0, it will ask for password change the first time foo logs in.In the previous post, I have written about installing apache mod_fcgid module to enable fastcgi support on apache. This time, I will write on how to install mod_fastcgi module to enable fastcgi module on apache installed on CentOS 5. Since by the time of this writing, there is no rpm for apache mod_fastcgi, we have to compile the mod_fastcgi module.
1. Install requirements for compilation
# yum install httpd-devel apr apr-devel libtool
# cd /opt
# wget http://www.fastcgi.com/dist/mod_fastcgi-current.tar.gz
# tar -xvzf mod_fastcgi-current.tar.gz
# cd mod_fastcgi-2.4.6
# cp Makefile.AP2 Makefile
# make top_dir=/usr/lib/httpd
# make install top_dir=/usr/lib/httpd
# /etc/init.d/httpd restart
# grep -i "FastCGI" /var/log/httpd/error_log
[Wed Aug 11 12:26:27 2010] [notice] FastCGI: process manager initialized (pid 8853)
For apache to support FastCGI, you have to install either mod_fastcgi or mod_fcgid. In this example, I will show how to install mod_fcgid on existing apache webserver on centos 5.
First of all, the rpm is available at kbsingh's centos testing repository.To install kbsingh's centos repository:
1. Download kbsingh-CentOS-Extras.repo to /etc/yum.repos.d/
# cd /etc/yum.repos.d
# wget http://centos.karan.org/kbsingh-CentOS-Extras.repo
# sed -i "s/enabled=0/enabled=1/g" /etc/yum.repos.d/kbsingh-CentOS-Extras.repo
# yum install mod_fcgid
# /etc/init.d/httpd restart
# httpd -t -D DUMP_MODULES
The application that we are going to use is chntpw. In this example, we will be using ubuntu livecd.
1. Put the livecd in the cd/dvd drive and boot your windows machine from the livecd.
2. Once booted, open the terminal and check for tool named "chntpw". If not there, you can install it using:
$ sudo apt-get install chntpw
$ sudo mount /dev/sda1 /mnt
$ cd /mnt/Windows/System32/config
List all user in the SAM record$ chntpw -l SAM
Interactively edit user credential$ chntpw -i SAM
To check hardisk information such as model and serial number, there are a few useful commands like hdparm, sdparm and fdisk.
To check the information about first hardisk for PATA and SATA hardisk:
# hdparm -i /dev/sda
# sdparm /dev/sda
# fdisk -lu /dev/sda
If you are using linux and administering a network full of windows machine, there is a tool called nbtscan to easily scan through the network and list all machines with their netbios name.
To install nbtscan in fedora:
# yum install nbtscan
# nbtscan 10.0.0.100
# nbtscan 10.0.0.0/24
# nbtscan 10.0.0.10-100
# nbtscan -h
To backup(dump) single mysql database to a file:
mysqldump -u foo -p foodb > foodb.sql
where -u is for username, -p is for mysqldump to ask for password, foodb is the name of the database and foodb.sql is the file to dump the database.
To backup(dump) all databases to a file:
mysqldump -u foo -p --all-databases > alldb.sql
where -u is for username, -p is for mysqldump to ask for password, --all-databases is to tell mysqldump to dump all databases available and alldb.sql is the dumpfile name.
To restore back mysql database from dumpfile:
1. From terminal
mysql -u foo -p foodb < foodb.sql
-u and -p are similar to above, foodb is the name of the database and foodb.sql is the name of the dumpfile.
2. From inside mysql console where you have to access mysql console first:
mysql> source foodb.sql
or
mysql> \. foodb.sql
where foodb.sql is the dumpfile
Usually, people will set basic authentication for apache directory (normally /var/www/html in centos). The reason is to protect the directory from unauthorized access. But what if a subdirectory inside (let say /var/www/html/mydirectory) needs full access? This is where .htaccess file comes into picture. To allow access to /var/www/html/mydirectory while maintaining authentication for /var/www/html, just follow below steps:
Allow from all
Satisfy Any
Sometimes we have to put our sites into maintenance mode for any reason, below is the easy way to do it for apache server in centos server.
1. Create a directory named err/ in the root directory. Lets say the site is called foo.bar
# cd /var/www/html/foo.bar
# mkdir err
2. Create a file named 503.html in the err directory
# cd /var/www/html/foo.bar/err
# touch 503.html
3. Put maintenance message into 503.html (this is an example, you can put whatever message you want, and you can put any name for the file :))
# echo "<html><b>This site is currently under maintenance. Thank you</b></html>" > 503.html
4. Add below lines to your virtual host setting for foo.bar
ErrorDocument 503 /err/503.html
## uncomment below to enter maintenance mode
RedirectMatch 503 ^/(?!err/)
Let's say we have one log file named logfile.log that contains a few lines like below:
192.168.1.1
192.168.1.10
192.168.1.11
192.168.1.111
When we want to search for 192.168.1.1, we usually will use:
$ grep 192.168.1.1 logfile.log
192.168.1.1
192.168.1.10
192.168.1.11
192.168.1.111
But unfortunately the result is not as what we expected(I assume we expect only 192.168.1.1 will come out) because grep will show to us all results "containing" the pattern given by us.
To overcome this problem, we have to use grep like this:
$ grep "192.168.1.1\>" logfile.log
192.168.1.1
Do not forget to put the double quotes, if not the command will not show any result.
That's all :)
Update:
Credit to sharuzzaman.blogspot.com for below technique, you can find the original post here
An alternative way to achive above result is by using -w flag of grep. So, instead of using grep "192.168.1.1\>" logfile.log, you can also use grep -w 192.168.1.1 logfile.log
To run windows cmd from linux box, there is one tool you could use, which is winexe. You can download the installer from here. There are 2 ways to install this tool:
install -s wmi/Samba/source/bin/winexe /usr/local/bin/winexe
When typing on the terminal, sometimes we need to record what commands we have typed for later reference. Sure, we can simply copy the .bash_history file, but that file only shows what you have typed and not the result of the commands that you have typed. To do these kind of jobs, there are two applications that you can use:
1. script
To use script, simply run script before you start using your terminal
# script -f logfile.log
where -f is to flush output after each write, and logfile.log is the file to write whatever script has recorded.
After finish using script, simply type exit or logout to quit script
2. rootsh
Please install rootsh first if it is not installed. To use rootsh, run rootsh before start using your terminal similar to script
# rootsh -f logfile.log --no-syslog
where -f is to show which file will be used to record the session, in this case logfile.log and --no-syslog is to tell rootsh not to log to /var/log/messages. To quit from rootsh, type exit or logout. All the commands and output will be written to logfile.log.closed to show that rootsh has closed the session.
Below are a few additional repositories that are available for CentOS 5:
To upgrade ubuntu server jaunty(9.04) to karmic(9.10):
To add /usr/local/bin to PATH in solaris 10 permanently for root:
To setup caching-nameserver:
1. Install bind, bind-chroot and caching-nameserver (bind is the nameserver, bind-chroot is to make bind operate in chroot environment and caching-nameserver is the BIND default setting for caching nameserver)
# yum install bind bind-chroot caching-nameserver
2. All bind configuration files will be stored in /var/named/chroot because of the bind-chroot package. A file named "named.caching-nameserver.conf" will be created in /var/named/chroot/etc. Rename the file to "named.conf"
# cd /var/named/chroot/etc
# mv named.caching-nameserver.conf named.conf
3. Edit named.conf until it become like below and save:
options {
listen-on port 53 { any; };
directory "/var/named";
dump-file "/var/named/data/cache_dump.db";
statistics-file "/var/named/data/named_stats.txt";
memstatistics-file "/var/named/data/named_mem_stats.txt";
allow-query { any; };
allow-query-cache { any; };
};
logging {
channel default_debug {
file "data/named.run";
severity dynamic;
};
};
view localhost_resolver {
match-clients { any; };
match-destinations { any; };
recursion yes;
include "/etc/named.rfc1912.zones";
};
4. Set /etc/resolv.conf to point to localhost
# echo "nameserver 127.0.0.1" > /etc/resolv.conf
5. Restart your nameserver
# /etc/init.d/named restart
Done :)
Dimdim is a web meeting software. From http://www.dimdim.com/products/what_is_dimdim.html: "Dimdim lets anyone deliver synchronized live presentations, whiteboards and web pages and share their voice and video over the Internet - with no download required".
There are few versions of dimdim, and the one we are going to install is the open source edition.
The steps are:
1. Download dimdim rpm from here
You have to provide email, first name and last name before you can download.
2. Once downloaded, unzip the file (Dimdim_RPM_Package_CentOS_5.2_v4.5.zip) and you can find one dimdim rpm file for Centos 5.2, one readme file, one web meeting user guide and one web meeting server integration guide.
# unzip Dimdim_RPM_Package_CentOS_5.2_v4.5.zip
3. Follow the installation guide in the Dimdim_SF_CentOS5.2_RPM_Readme_v4.5.txt file. After finish with all the pre-requisite check, proceed to installation process.
4. If you have error stating that you have failure in OS check, change your /etc/issue from 5.4 to 5.2
# sed -i 's/5.4/5.2/' /etc/issue
5. If you got an error in missing libpcre, install pcre
# yum install pcre
6. Once installed, open your browser and point your browser to http://localhost/dimdim
7. Start meeting using your newly installed dimdim :)
Virtual ip is an ip that bind to a physical ethernet card that already have physical ip address. To set virtual ip in centos, follow the below steps:
1. We will add virtual ip to eth0. Below is original configuration of /etc/sysconfig/network-scripts/ifcfg-eth0. ifcfg-eth0 is the original configuration file for eth0.# vi /etc/sysconfig/network-scripts/ifcfg-eth0
BOOTPROTO=static
BROADCAST=192.168.0.255
HWADDR=00:0C:29:C8:AA:7C
IPADDR=192.168.0.10
NETMASK=255.255.255.0
NETWORK=192.168.0.0
ONBOOT=yes
TYPE=Ethernet
BOOTPROTO=static
BROADCAST=192.168.0.255
IPADDR=192.168.0.11
NETMASK=255.255.255.0
NETWORK=192.168.0.0
ONBOOT=yes
TYPE=Ethernet
Alias is some kind of shortcut in command lines, and it can be really productive if you can alias all the long commands that you use to manage your linux system.
Example:
To permanently set alias "d=dmesg | tail" for user "abu"
1. Append "alias d=dmesg | tail" to the /home/abu/.bashrc
$ echo "alias 'd=/bin/dmesg | /usr/bin/tail'" >> /home/abu/.bashrc
2. Activate the change
$ . /home/abu/.bashrc
3. Test the new alias
$ d
[drm] LVDS-8: set mode 16
[drm] LVDS-8: set mode 17
[drm] LVDS-8: set mode 18
[drm] LVDS-8: set mode 19
[drm] LVDS-8: set mode 1b
[drm] LVDS-8: set mode 1d
[drm] LVDS-8: set mode 1e
[drm] LVDS-8: set mode 1f
[drm] LVDS-8: set mode 20
[drm] LVDS-8: set mode 21
To temporarily set alias, just use the alias command at the terminal
$ alias d='dmesg | tail'
To remove alias. you can either delete it from ~/.bashrc or use unalias command
$ unalias d
Stalled scp file transfer session will happen when the network connection is unstable. You can see the status of the session at the message shown at your stdout like below:
file1 3% 136MB 0.0KB/s - stalled -
To continue back the file transfer, you can use this command at a new terminal, but make sure both the server and client have rsync installed:
$ rsync --partial --progress --rsh=ssh username@server:/path/to/remote-file /path/to/local-file
For example, if the transfer of file1 is stalled for user abu:
$ rsync --partial --progress --rsh=ssh abu@master:/home/abu/file1 /home/abu/file1
The scp transfer process will continue transferring the file
file1 4% 136MB 300.0KB/s 2:03:17 ETA