Following command copies all (non-hidden) files, including any subdirectories from /home/Hashir to /mnt/myfolder

[root@pim /]# cp /home/Hashir/* /mnt/myfolder

The above command will change the ownership of the newly copied files on /mnt/myfolder to the uid and gid of the user issuing the copy (cp) command, in this case the user root. To preserve the file permissions while copying to the new location, use the -p switch as well. For example:

[root@pim /]# cp -v -r -p /home/Hashir/* /mnt/myfolder/

Following command deletes all files, including subdirectories, forcefully (without asking yes/no) from the directory /tmp.

[root@pim /]# rm -fr /tmp/*

Following command creates a tar file in /tmp as mytar.tar from the files in current directory

[root@pim /]# tar cvf /tmp/mytar.tar *

Following command extract the tar file mytar.tar from /tmp in current directory

[root@pim /]# tar xvf /tmp/mytar.tar

Following command extract the tar file mytar.tar from /tmp in /backup/restore

[root@pim /]# tar xvf /tmp/mytar.tar -C /backup/restore

Disk checking and formatting:

List of all partitions on all attached hard drives (both SCSI and IDE)

[root@pim /]# fdisk -l

To resize partitions use:

[root@pim /]# parted

Following command formats a floppy disk in ext2 format, also checks for and marks, bad sectors

[root@pim /]# mke2fs -c /dev/fd0

Following command formats a floppy disk in dos format

[root@pim /]# mkdosfs /dev/fd0

Following command checks for errors on the partition, the partition being checked should be in unmounted state during check.

[root@pim /]# e2fsck /dev/hda3

or

[root@pim /]# fsck -t ext2 /dev/hda3

Process management:

Following command shows the list of all running processes with their process ids (PID), even owned by other users:

[root@pim /]# ps aux | less

You can also use pstree :

[root@pim /]# pstree

Following command will kill a specific process, say process id 12432:

[root@pim /]# kill 12432

or

[root@pim /]# kill –s KILL 12432

or

[root@pim /]# kill –KILL 12432

or

[root@pim /]# kill –9 12432

User Management and file permissions / ownerships:

To add a new group called database use:

[root@pim /]# groupadd database

To add new user Hashir and make him a member of the group database, use:

[root@pim /]# useradd -s /bin/bash -g database Hashir

To change the password of user, run the following command:

[root@pim /]# passwd Hashir

To lock the password of user Hashir, run the following command as root:

[root@pim /]# passwd -l Hashir

To un-lock the password of user Hashir, run the following command as root:

[root@pim /]# passwd -u Hashir

To delete a user say Hashir, including his home directory, use:

[root@pim /]# userdel -r Hashir

To change permissions of an object (file or directory), use chmod:

[root@pim /]# chmod 770 myfile.txt

(changes the permissions of the file to rwx for both owner and group)

or

[root@pim /]# chmod ug+rwx,o-rwx myfile.txt

To change ownership of a directory /project to Hashir and set the group permissions to the group database, use chown (-R will change ownership of all files and subdirectories under the directory project:

[root@pim /]# chown –R Hashir:database /project

Package management :

Following command lists all the currently installed packages and captures only those lines which have the word samba in them

[root@pim /]# rpm -qa | grep samba

or

[root@pim /]# rpm -qa sambal*

To check presence of the package 'bind' in the system, use the following command:

[root@pim /]# rpm -q bind

Following command lists all the information about the specific installed package.

[root@pim /]# rpm -qi samba

Following command lists all the documentation files and their location of a particular installed package.

[root@pim /]# rpm -qd samba

Following command lists file locations of all of the files of a particular installed package.

[root@pim /]# rpm -ql samba

Following command lists all information of the un-installed package:

[root@pim /]# rpm -qpi ymessenger-0.99.19-1.i386.rpm

Similarly,you can check the list of files a package contains, before actually installing it:

[root@pim /]# rpm -qpl ymessenger-0.99.19-1.i386.rpm

Install different programs from SLES-11 DVD If program not installed, by using the following command:

[root@pim /]# rpm -ivh /mnt/dvd/sles-11/RPMS/samba*.rpm

If an older version of the package is installed and you want to upgrade it to a new version, then use (U):

[root@pim /]# rpm -Uvh /mnt/dvd/sles-11/RPMS/samba*.rpm

Following command erases (removes / un-installs ) a specific package.

[root@pim /]# rpm -e samba

Miscellaneous:

To find help on some topic :

[root@pim /]# man samba

or

[root@pim /]# info samba

To find a file in the /mnt directory, use:

[root@pim /]# find /mnt -name “*.doc” -print

To find files and directories owned by the group database in the /mnt directory, use:

[root@pim /]# find /mnt -group database

Assuming a user left the organization and the files owned by his account name must be found and deleted for security reasons, use :

Comments

Post a Comment

Popular posts from this blog

In a database management system, a stored procedure is a set of Structured Query Language (SQL) statements with an assigned name that's stored in the database in compiled form so that it can be shared by a number of programs. The use of stored procedures can be helpful in controlling access to data, preserving data integrity and improving productivity.

The
Oracle PL/SQL language allows you to write procedure to
centralize the business logic and store the code in the database.

I have created the following Stored Procedure on Oracle using TOAD. This particular Stored Procedure will Insert a Customer to the Customer Table. For the sake of simplicity, Customer Table contains only 4 columns (Customer ID, Customer Name, City and Contact No).

In this post I will show you how to create Oracle stored Procedure using TOAD. Connect to Oracle Database using TOAD. Click on Database menu and open Schema Browser.

A package is a group of procedures, functions, variables and SQL statements created as a single unit. It is used to store together related objects. A package has two parts, Package Specification and Package Body.

Package Specification

Package Specification acts as an interface to the package. Declaration of types, variables, constants, exceptions, cursors and subprograms is done in Package specifications. Package specification does not contain any code.

Package Body

Package body is used to provide implementation for the subprograms, queries for the cursors declared in the package specification.

In this tutorial I am sharing how to create a table in Oracle Database using TOAD for Oracle Software. A table is a database object created by users to store data in the form of rows and columns. A table is the basic unit of storage. Table can be created at any time, even while users are accessing the database. A database table consists of column that needs to be defined when creating the table. Table can have up to 1,000 columns. A table must conform to some standard database object-naming conventions. Follow the given below steps to create table in Oracle Database using TOAD software.