Category: Linux

What is RHCE?

RHCE neel h pathak

RHCE neelpathak.wordpress.com

RHCE i.e. RedHat Certified Engineer is considered as most respected certification in Linux Community. The certification actually consists of three Modules viz. SA1, SA2 and SA3. Any person who wish to get RHCE certified needs to clear two exams. They are:

1) RHCSA i.e. RedHat Certified System Administrator which comprises of two Modules SA1 and SA2.
2) and RHCE which comprise of Third Module i.e. SA3.

There are many and immediate job openings in some of the well known Information Technology firms of India like Infosys, TCS, TechMahindra for those who clears RHCE exam and also for those who possess knowledge of RHCE.

Below are the topics (course content) discussed in all the three Modules (Official Curriculum) RHCE 6

SA1:
GNOME Graphical Desktop, managing files with Nautilus, get help in graphical environment, configure local services, bash, managing physical storage, system resourses monitoring, managing locical volumes, getting help in texual environment, network connectivity, user and groups, manages files from command line, secure linux file access, remote systems, control boot process, deploy file sharing services, manage virtual machines, install linux graphically, configure general services and secure network services.

SA2:
Automated installation of Linux, accessing the command line, intermediate command line tools, regular expressions, network config and troubleshooting, managing simple partitions and file systems, flexible storage with LVM, accessing NFS services, managing user accounts, network user accounts with ldap, controlling access to files, managing SELinux, installing and managing software, managing installed services, tuning and maintaining the kernel and system recovery techniques.

SA3:
Enhance user security, bash scripting, file security with GpG, package management, network monitoring, advanced network configuration, secure network traffic, NTP server configuration, system monitoring and logs, centralized and secure storage, SSL encapsulated web servcies, web serever additional configuration, basic smtp configuration, caching only dns servers, file sharing with NFS and CIFS, file sharing with ftp and troubleshooting the boot process.

When you clear first exam, you are considered as RHCSA (which contains SA1 and SA2) and when you clear second exam then you are a certified RedHat Engineer (which contains module SA3).

So, its basically a beginning level certification which bears utmost importance in Linux Community. I think I have now cleared doubts regarding RHCE. For more information you can visit Official Website.

Users and Permissions on Linux (CentOs)

Header

Today I am going to write about users, groups and their permissions on certain files and directories on CentOS. On other distros the procedure may very slightly but the concepts are all the same. Here I`ve used CentOS version 6.4 (This is hands on tutorial, Part 1)

USERS:
It is always a nice idea to create users according to their respective work on PC/workstation. And its easy to create users on Linux OS.

To add user, first open terminal(Applications -> System Tool -> Terminal) and type “useradd” followed by the name of the user you want to create. Below is its snapshot.

Neel H Pathak, Hacker

Note: If you get message like “Permission Denied”, then it says that you are not having enough permissions to create user. Simply switch to super user(root user) by typing “su -” and provide password for the super user(root user)

Above we created user with the name “alice”.

Remember, by default every user has its home directory and it has “/home/<username>” path. Below is the snapshot showing just that.

2

Remember that by default every user is present into its own group named same as user name.

Every user account is worthless without any password assigned to that user. So lets assign password to user named “alice”. This is done with the command “passwd” followed by the username. Below it is shown.

Neel Pathak HackerAs you can see that we just assigned password as “alice” to user named “alice”. As this password was relatively simple, so OS gave warning but we assigned our password successfully thereby again confirming our password. The command is shown in dark blue color and warning message is shown in red box.

Now, just logout from this session (username -> quit) and login to user named “alice”. Open terminal and type command “ls -l” (shown in red). You can notice that all the directories appeared as Desktop, Documents, Downloads, Music, Pictures etc. in the alice home directory. Below it is shown in the snapshot. This directories were not before when we created the user from the super user account.

4

5

Try to change the password by the same command, just type “passwd” without username as we are already logged in with “alice” user so we will not give the username. If you give the username after command “passwd” then it will give an error stating “passwd: only root can specify user name”, means that when we are logged in as root then and then only we can give username after “passwd” command.

Now, if you will provide any simple password like that has same name as username or any dictionary based word then it will simply not allow you to change the password. But this was not the case earlier when we gave a simple password when we were logged in as super user(i.e. root user). Ahha that power to Super user. Amazed!!

Again login as super user (or root user) and create a user named “bob” and we will change its default directory`s name to something else. This can be done from the command “useradd” followed by giving option “-d” and its path and then username.

“useradd -d /home/notbob bob” (Snapshot shown below)

6

Remember, we just created different home directory for the user and not different group for these users. The users have the same name as that of their username unless changed. (See the snaphot below)

7

As shown above, “bob” user has same name of group as its user name i.e. “bob” group. Also it is shown in second example, there is “pathak” user which has “pathak” group by default and other home directory.

Lets create a user belonging to different group. For this there is a small change in command especially the switch of that command. We will create user named “jhon” belonging to the group “bob”.

“useradd -g bob jhon”

Neel hackerIt is also possible that a single user can belong to many groups. Lets see how.

“useradd -G bob,alice abraham”

So, we have user abraham belonging to three groups, yes THREE groups. The first and default is “abraham” and other two are “bob” and “alice”

9

Amazed again?? Don`t be.

Remember: Whenever you create a user belonging to other groups, the default group is always there and its name is same as the user created with the same restriction of the group.

Also we can know whether the user is present or not from “id” command. It also shows other groups which that user belongs to. (Shown above)

Note: You can get full information about “useradd” cmd by referring its man pages. Just type “man useradd” on your terminal.

One can also look at the command “usermod”, just type “man usermod” to check options.

Pheww… Enough talking about users and groups now lets talk about permissions.

Permissions:
You can assign permissions to any files or directories under Linux.

Lets check it how.

First lets login to one of the account just created above, lets say we are logged in as user “alice” (snap below)

10

Now, lets create a directory under documents directory and then lets create a test.txt file. (Shown Below in snap)

11

Change to some other user say “abraham” and try to enter into “alice” home directory, what do you notice? Yes you are right, you can`t enter into “alice” home directory from other user account. (Snap shown below)

12

Lets, add user “abraham” to the group named “alice”, we will do this by using command “usermod” (snap shot below)

13

Note: When you create any user you can specify groups explicitly there. But suppose the user is created and then you want to change its properties, then use “usermod” command.

Again lets try to login as “abraham” and again access the same directory i.e. “alice” home directory, what you notice?

Eventhough “abraham” user belongs to both the groups “alice” and “abraham”, it is not able to still access that directory. This is because when we check its permissions we can come to know that what permissions exits on that directory.

Check its permissions with “ls -l” (Snap shot below)

14

Remember that the permissions follow in a specific order,

1) User permission
2) Group permission
3) Other permission

Earlier we just added our user “abraham” to the group named “alice” to access alice`s home directory. But we have not specified the permission for the group/groups in which it is present.

So, lets give group/groups a permission of r,w and x (r=read, w=write and x=execute). This can be done with “chmod” command. And again check the permission (Snapshot is shown below)

15

Note: Execute this command with root privileges.

Note:When we create a user, then the permissions are in restrictive mode by default. We need to change them according to our needs.

Commands that you can check for permissions are

1) chown
2) chgrp
3) chmod

Just open manual pages and go through it like “man chmod”.

Importing And Exporting Mysql Database to Local System and to the Server.

There are times when you need to export or import your Mysql database, this is usually when you are migrating from one server to other server or making some changes to the database and again exporting back to the server. Here I show you both the ways importing/exporting Mysql db to local system  (localhost) and importing/exporting Mysql db to a dedicated server.

Importing/Exporting Mysql DB on a dedicated Server

Importing (Sending DB to Server from PC by .SQL file)

1)Login into your server through SSH

ssh <name>@<server name>

or

ssh -l <login username> <IP address>

2)A password prompt will come, enter the correct password for SSH (You can`t see the password)

3)Now with the help of terminal navigate to the directory where your .SQL file is pressent.

4)You need to import the Mysql DB. For importing run the following command/s

mysql -h <servername> -u <username> -p <dbname> < <dbname.sql>

OR

mysql -h <servername> -u <username> -p <dbname> -e ‘source dbname.sql’

OR You can force the command to execute any way

mysql -f -h <servername> -u <username> -p <dbname> -e ‘source dbname.sql’

-f option to force the command

* Remember you must create an appropriate database according to your application (like dbname) and then only must import the DB.

5)A prompt for Mysql password will come, enter the correct password and you are done :).

Exporting (Recieving .SQL from Server to PC)

1)Login into your server through SSH as mentioned above.

2)Navigate to the directory in Server where you want to export .SQL file (later you can take this file from FTP by logging into it).

3)Enter the command below for exporting the database.

mysqldump –add-drop-table -h <servername> -u <username> -p <dbname> > <dbname.sql>

4)Enter your mysql password correctly.

5)You can now download the resulting SQL file. Connect to your server with FTP, navigate to the directory where you created the dump file, and download it. 🙂

 

 

Now as we have done the hard stuff, Importing/Exporting to localsystem is really easy and hassle free.

Exporting (Sending DB from Mysql localhost to any of your Hard Drive)

1)To dump the database and gzip it at the same time, use the following. This will prompt you for your password.

mysqldump -u [USERNAME] -p [DBNAME] | gzip > [/path_to_file/DBNAME].sql.gz

Importing

if you want to replace the database with a fresh dump created by the above process, do the following.

1)First, unzip the file.

gzip -d [/path_to_file/DBNAME].sql.gz

2)Get to a mysql prompt (you will be asked for your password.)

[/path_to_mysql/]mysql -u [USERNAME] -p

3)Then do the following to wipe out the old database and replace it with the new dump:

SHOW DATABASES;
DROP DATABASE [DBNAME];
CREATE DATABASE [DBNAME];
USE [DBNAME];
SOURCE [/path_to_file/DBNAME].sql;

More information about conditional dumping can be easily found on internet.

Remove login and admin cmd history on linux ubuntu.

Just follow these commands and you will be able to remove login and admin cmd history.

1) Open the terminal

2) Enter “sudo -i” command.

3) Using echo to overwrite history.Enter the following commands in terminal

“echo >/var/log/wtmp”

“echo > /var/log/btmp”

4)  Now to clear the cmd history. Enter the following commands.

"history -c" or "echo > ./.bash_history"

Now you can enter "last" or "lastb" to check whether the login history has been removed 
or not.

Install LAMP (Linux Apache Mysql Php/Perl) ubuntu 10.10

Follow the commands and you will be able to install LAMP package into your LINUX system. Think Open Think Free..

1) Open your terminal( remember terminal for linux and console for windows)

2) Get the Admin rights by issuing this command into your terminal “$sudo su”, Enter the password for admin.

3) Now, type “#apt-get install tasksel”

4) When tasksel is installed , open it in by entering the following command “#tasksel”

5) Select the LAMP suit in it by pressing SPACE key, and press enter.

Image Lamp Suite6) Hurray LAMP suit is installed in your linux machine 🙂