Leave last few lines and delete all
How do I delete a huge file except last n lines of a file?
vi editor has a feature called "ex", By using it you can delete all lines of a file except n lines from a file
Create a file with n lines
# for i in $(seq 1 2500); do ..
Using nscd command to flush dns cache
The nscd caches are saved to disk on RedHat system, they are located in /var/db/nscd
# ls /var/db/nscd/
group hosts netgroup passwd services
When you stop or restart nscd these files just stay there and restarting really wont clear or flush your ..
Covert Kilobytes to Megabytes or gigabytes of disk
To find the disk size
# fdisk -s /dev/sdb
In the above command the disk space will be printed in KB. But I had the requirement to print the values in MB or GB for multiple servers.
To print diskspace in Megabytes or MB
# echo ..
Covert Kilobytes to Megabytes or gigabytes through terminal
When I tried to run size of my memory, I executed below command and found the result in KB
# grep 'MemTotal' /proc/meminfo
I can also run free -m or free -g to read the output in MB or GB. But when I have list of values in ..
Running rhq agent as a Daemon or init.d Service
Normally the agent should be started as a background daemon process. On Windows, this runs as a service. On Linux and Unix
systems, the agent starts at boot time from init.d
Register rhq-agent-wrapper.sh with chkconfig.
# /sbin/chkconfig --add rhq-agent-wrapper.sh
Enable the agent service to run at boot time and have it ..
Change ownership for symbolic link
The chown command changes the user ID and/or the group ID of the specified files. Symbolic links named by arguments are silently left unchanged unless -h is used.
Changing the owner of a symbolic link needs special attention. When you use chown the regular way to change the owner of a ..
Installing Ansible Playbook
Great things about Ansible is that you dont need to install an Ansible client on the servers you are managing. You only need to install Ansible on your local machine or on a master server that can connect to the managed servers via SSH. Ansible works by configuring client machines ..
Format disk using dd command
When you want to clean the disk or format the disk dd command will be very handy to use it.
Format disk using dd command
# dd if=/dev/zero of=/dev/sdb
# dd if=/dev/null of=/dev/sdd bs=4096 count=1
This command will clean or wipe the data of your existing disk. Use this command ..
Mount partition with ntfs file system and read write access
Today when I want to mount my external harddisk I felt uneasy since my Redhat linux does not support nfts partiton. NTFS3G is an open source cross-platform, stable, GPL licensed, POSIX, NTFS R/W driver used in Linux. It provides safe handling of Windows NTFS file systems. To proceed with mounting ..
Yum only download not to install
How to yum download a package without installing?
Install downloadonly plugin for download option
# yum install yum-utils
# yum install yum-plugin-downloadonly
How to yum download a package?
# yum install --downloadonly --downloaddir=<directory> <package>
# yum install --downloadonly --downloaddir=./ kmod-VirtualBox-3.19.5-200.fc21.x86_64.x86_64
To download already installed packages
# yumdownloader <package>
How to find block size of partition
How do I find block size of an partition on Linux?
# tune2fs -l /dev/sda1 | grep -i 'block size'
Block size: 1024
How do I find block size of a filesystem on Linux?
How to install google chrome in fedora 21 22
As we all know google chrome is now becoming one of the most used browser, Its easy and simple to install in linux by following the below steps. To install Google Chrome in Fedora 20 / 19 / 18 / 17 / 16 / 15 / 14 and RHEL using ..
Error VLC is not supposed to be run as root
Today I installed VLC as root and when I tried to execute or run vlc player I received error VLC is not supposed to be run as root.
Installing VLC: To install VLC, your rpmfusion repo must be configured
RPMfusion Free Release
# yum localinstall --nogpgcheck http://download1.rpmfusion.org/free/fedora/rpmfusion-free-release-$(rpm -E %fedora).noarch.rpm
RPMfusion NonFree Release
Find shells present in server
chsh -l will list all the available shells in the
# chsh -l
chsl --list-shell will also print he same result as chsh -l
# chsh --list-shell
What is sticky bit, SUID, SGID
what is "sticky bit", "SUID" , "SGID"?
1) Sticky bit was used on executable in Linux (which was used more often)so that they would remain in the memory more time after the initial execution, hoping they would be needed in the near future. But since today we have more sophisticated memory ..