How can I force fsck on next boot on Red Hat Enterprise Linux?

By default, the fsck utility is run on every boot. For ext3 filesystems, the boot scripts do a quick check to see if the filesystem journal indicates the file system is clean. If the initial check passes no further checking is performed. Otherwise, the user is prompted to run a full fsck check.

You can force an automatic full check by changing the check interval using tune2fs (-c and/or -i). For example:

# tune2fs -c 1 /dev/hda2

The above command would tell the init scripts to run fsck on hda2 at every boot.

# tune2fs -i 1d /dev/hda2

The above command would tell the init scripts to run fsck on hda2 after 1 day.

If you only want to run fsck on the next boot, please execute the following as the root user:

# cd /
# touch forcefsck

This will only run the file system check on the next reboot. By touching the file “forcefsck” in the / directory, it will force the system to perform a full file system check.

The file “forcefsck” will be deleted automatically after fsck is finished.

Note: For systems with large disks, fsck on boot may take a long time to run depending on system speed and disk sizes.

How to reload sysctl.conf variables on Linux

The sysctl command is used to modify Linux kernel variables at runtime. The variables are read and write from /proc/sys/ location using procfs. The syntax is as follows for to define variable:


Read variable from command line

Type the following command
$ sysctl kernel.ostype
Sample outputs:

kernel.ostype = Linux
To see all variables pass the -a option:
 $ sysctl -a
 $ sysctl -a | grep kernel
 $ sysctl -a | more

Write variable from command line

The syntax is:
# sysctl -w variable=value
To enable packet forwarding for IPv4, enter:
# sysctl -w net.ipv4.ip_forward=1

Reload settings from all system configuration files

Type the following command to reload settings from config files without rebooting the box:
# sysctl --system
The settings are read from all of the following system configuration files:

  1. /run/sysctl.d/*.conf
  2. /etc/sysctl.d/*.conf
  3. /usr/local/lib/sysctl.d/*.conf
  4. /usr/lib/sysctl.d/*.conf
  5. /lib/sysctl.d/*.conf
  6. /etc/sysctl.conf

Persistent configuration

You need to edit the /etc/sysctl.conf file for setting system variables:
# vi /etc/sysctl.conf
Modify or add in the file. Close and save the file. To Load in sysctl settings from the file specified or /etc/sysctl.conf if none given, enter:
# sysctl -p



Installing a MySQL Server on CentOS

MySQL is an open-source relational database that is free and widely used. It is a good choice if you know that you need a database but don’t know much about all of the available options.

Note: CentOS 7 has replaced MySQL with MariaDB. To reflect this, instructions for MariaDB procedures are included in this article.

Install the MySQL database through the CentOS package manager (yum) by running the following commands at a command prompt:

#sudo yum install mysql-server
#sudo /sbin/service mysqld start

Run the following command:

sudo /usr/bin/mysql_secure_installation

Press Enter to give no password for root when prompted for it.

To apply some reasonable security to your new MySQL server answer yes to all the prompts. In order, those prompts enable you set the root password, remove anonymous users, disable remote root logins, delete the test database that the installer included, and then reload the privileges so that your changes will take effect.

Install MariaDB

Install the MariaDB server through the CentOS package manager (yum) by running the following command at a command prompt:

sudo yum install mariadb-server mariadb

Allow remote access

If you have iptables enabled and want to connect to the MySQL database from another computer, you must open a port in your server’s firewall (the default port is 3306). You don’t need to do this if the application that uses MySQL is running on the same server.

If you need to open a port, add the following rules in iptables to open port 3306

iptables -I INPUT -p tcpdport 3306 -m state –state NEW,ESTABLISHED -j ACCEPT
iptables -I OUTPUT -p tcp –sport 3306 -m state –state ESTABLISHED -j ACCEPT

Start and stop the database service

After the installation is complete, you can start the database service by using the commands in this section. If the system is already started, a message informs you that the service is already running.

Start and stop MySQL

Use the following command to start MySQL:

#sudo /sbin/service mysqld start

Use the following command to stop MySQL:

sudo /sbin/service mysqld stop

Start and stop MariaDB

Use the following command to start MariaDB:

#sudo systemctl start mariadb.service

Use the following command to stop MariaDB:

#sudo systemctl stop mariadb.service

Launch at reboot

To ensure that the database server launches after a reboot, you must enable the chkconfig utility. Use the following commands to do this.

Enable chkconfig on MySQL

#sudo chkconfig mysqld on

Enable chkconfig on MariaDB

#sudo systemctl enable mariadb.service

Start the mysql shell

There is more than one way to work with a MySQL server, but this article focuses on the most basic and compatible approach: the mysql shell.

At the command prompt, run the following command to launch the mysql shell and enter it as the root user:

#/usr/bin/mysql -u root -p
When you’re prompted for a password, enter the one that you set at installation or, if you haven’t set one, press Enter to submit no password.

The following mysql shell prompt should appear:


Set the root password

Because you have just installed the MySQL database server, the root account within MySQL has no password set yet. If you are logged in to the database server, set the root password by running the following command:

#/usr/bin/mysqladmin -u root password ‘new-password’

If you are not logged in to the database server you can remotely set the root password by specifying the hostname of your database server:

#/usr/bin/mysqladmin -u root –password=’new-password’ -h hostname-of-your-server ‘new-password’

How we get networking on Linux

How we get networking on Linux

just three commands.

Step One: Set Your IP Address

ifconfig eth0 netmask up

Step 2: Set Your Default Gateway

route add default gw

Step 3: Set Your DNS Server

echo “nameserver” > /etc/resolv.conf

That’s it.

Assuming you have valid addresses for yourself and your gateway


Running Process in Background on Linux

Adding & the end of the command

On Linux/Unix based systems you can put a task (such as command or script) in a background by appending a & at the end of the command line. In other words, you can say that easily send any process in the background.

# command &
# script-name &

# find / -name *.c > /root/output.txt &

Using & with nohup
You can use nohup command line-utility which allows to run command/process or shell script that can continue running in the background after you log out from a shell:

# nohup command-name &
# nohup find / -size +1k > /root/output.txt &