Some useful commands for intermediate users of  Linux.

Change access to super user or change user to superuser

su -

This will prompt you for the password for the super user.

Check your login name (currently you are logged in as)

whoami

Check your present directory (Present Working Directory)

pwd

Check date of the system

date

date command supports multiple parameter so that you can check date in different formats.

for getting help for any command

command --help

for viewing manual for any command

man command

opening any file in vi editor

vi file_name

or

vi file_name_with_path

printing content of any file on standard output (shell)

cat file_name

or

cat file_name_with_path

Here are few very useful Linux command for beginers

List contents of directory

ls


List all contents of directory (Including hidden files and sub-diretcories)

ls -a


View file / folder attributes

ls -l


View file size in human readable format (in KB, MB ..)

ls -lh


copy file

cp /path_of_source_file /path_of_destination_directory


copy folder with all its content

cp -r /path_of_source_folder /path_of_destination_directory

move file

mv /path_of_source_file /path_of_destination_directory

move folder and its content

mv -r /path_of_source_folder /path_of_destination_directory

delete file

rm filename


delete file name with force option

rm -f filename


delete folder and all its content

rm -rf foldername

To create Subversion repository under the Apache Linux Platform follow the following steps :

1. create repository :

svnadmin create _PROJECT_

2. change permissions :

chown -R apache:apache _PROJECT_

3. create valid user and password :

htpasswd -cb secret_file _USER_ _PASSWORD_

4. add user to svnauth.conf :

vi svnauth.conf

Rough structure of the svnauth.conf file

[groups]
##NOTE THESE ARE THE ADMIN USERS YOU CREATED WITH THE HTPASSWD COMMAND
svn-admins = admin, brashr , _USER_

########################################################
## Repository: DEFAULT since this is the only repos thats using permissions
########################################################
[/]
@svn-admins = rw
* = r

5. edit subversion.conf in /etc/httpd/conf.d/ :

Add following code to subversion.conf

<Location /repo_url_path_to_access_svn>
DAV svn
SVNPath /file_path_to_repo
AuthType Basic
AuthName "SVN authorization for Project"
AuthUserFile /file_path_to_secret_file
AuthzSVNAccessFile /file_path_to_svnauthz.conf
Require valid-user
</Location>

6. Restart Apache :

/etc/init.d/httpd restart
MySql Provides the Basic backup using command mysqldump. This is powerful command and can take backup as a SQL CREATE TABLE and INSERT INTO TABLE commands. The output is in a text file and you can directly run this text file on the command MySql command prompt for restoring the database.

Backup Database :

Using mysqldump command is one of the way to take backup. This command runs through the windows command prompt or the Linux shell prompt. You can use the command as follows :
C:>\ mysqldump -p -u root --databases db_name > backup1.sql
$ mysqldump -p -u root --databases db_name > backup1.sql

This will prompt you for entering password for the user “root”. After successful authentication and authorization the SQL file “backup1.sql” will be created in your C:\ .
While having this command as a backup tool, MYSQL provides the LOCK TABLES , UNLOCK TABLES , DISABLE KEYS and ENABLE KEYS command . This helps you while restoring database.

For Backing up specified tables only from database. Use following command.

C:>\ mysqldump -p -u root --databases db_name --table table_name1 table_name2 > backup1.sql
mysqldump -p -u root --databases db_name --table table_name1 table_name2 > backup1.sql


Restoring Database :

There are two ways of restoring database created with the backup command. One is to use command line utility and another is run SQL command.

Using Command Line :

For restoring The database using Command Line use following Command :

C:>\ mysql -p -u root db_name < backup1.sql
$ mysql -p -u root db_name < backup1.sql


Using SQL query :

For restoring using SQL query you will need to log in into MySQL database first.After logging into MySQL run following query :

mysql> source c:/abc.sql


Back Up Database as Compressed File (Linux):

Using command line power of Linux you can convert the sql file into a compresed file as the mysqldump generates the SQL file.

$ mysqldump -p -u root --databases db_name --table tblname | gzip > backup1.zip



Restoring Database from compressed file (Linux) :

You can restore the compressed file using following command.

$ gzip < backup1.zip | mysql -p -u root db_name

Me MySelf and I

Posted: November 8, 2009 in Personal
Tags:

I am a simple guy originally from a small town Sangameshwar in Maharshtra , India. I had been man places nearby like Dapoli, Chiplun, Ratnagiri. As basically from town , I love the nature more than the busy scheduled cities. but at the same time I invest my most of the time on internet, keeping in touch with technology news. For me most important things are family , relatives and friends.

As a Profession I am a Programmer. I have worked in many technologies under various platforms for past few years. My main expertise are in Java related technologies and related Open source technologies. I have worked on all JAVA editions namely JAVA, J2EE and J2ME. As a web developer I have also worked with the other web development languages such as PHP 5.0 and Ruby on Rails. I have also worked on J2ME , Blackberry as a mobile developer