Blog Archive

Tuesday, December 29, 2009

adding xp recovery console to boot menu option

I thought of adding a boot menu option of recovery console so when i
have a problem i could use it,such as chkdsk if i cannot logged in
,but not the NT bootloader, cos it cant even reach the boot menu ;)).

ok, here how it goes :
download the modified zipfile here
http://www.mediafire.com/download.php?lzjyizzntfn
Before starting, pls extract the zip file to your easy to find folder
because you will have to run mkbt.exe tool in command prompt to create
a bootsector file.

1. Copy all the files from the folder "Copy the files inside to your C drive"
to your Windows XP boot drive (in this case i use c:\)

2. Run Command Prompt (cmd),go to extraction folder and type :
mkbt.exe -x -c C: C:\rcboot.bin

3. run the hexeditor (double click HexEdit.exe).
open file rcboot.bin that you have created and do a find replace string

find string 4E0054 (use ctrl+F)
replace with 43004D

then save the file.

4. Open boot.ini file in your C drive and add the following line :

c:\rcboot.bin="Microsoft Windows XP Recovery Console" /cmdcons


hope thats work,it works for me .. gud luck !!

Monday, December 28, 2009

Receive email anonymously

Yopmail



Yopmail is a free service that lets you create a disposable, anonymous email address. Messages on your temporary Yopmail inbox are stored for 5 days and you can check them via a dedicated Firefox extension or widget. No registration process is needed.

http://www.yopmail.com/en/

Friday, December 25, 2009

Change vsftpd login default path

The default anonymous login directory is /var/ftp/
To change the default from /var/ftp to any other directory (say /data)
edit /etc/vsftpd/vsftpd.conf file add entry.
local_root=/data
save the file and restart the vsftpd services using command
services vsftpd restart.

Change the default ftp user account home folder to point to the new location.
before change ftp account info in /etc/passwd file
ftp:x:14:50:FTP User:/var/ftp:/sbin/nologin
chmod -d /data ftp # To change the home directory for ftp user.(This is optional for read only access)
ftp:x:14:50:FTP User:/data:/sbin/nologin
Now when you login as anonymous user, the login directory will be /data.

Friday, December 18, 2009

Make SMTP mail server in xp

Install IIS SMTP Service

You can install IIS on Windows 2000/XP as follows: "Control Panel->Add/Remove Programs->Windows Components->Internet Information Service->SMTP Service". For Windows NT user, you can install it from Option Pack 4.0 of Windows NT. After installed, you can start it from "Control Panel->Administrative Tools->Internet Information Service".

ESMTP authentication/Trusted IP Addresses

The default setting of IIS Smtp service may cause failure in sending email ("Error with sending recipient"). Here are two solutions to the problem.

Enable ESMTP authentication of IIS SMTP Service

1. "Control Panel->Administrative Tools->Internet Information Service->Default SMTP Virtual Server->Properties->Access->Authentication. ". Check the BASIC Authentication.

2. "Control Panel->Administrative Tools->Internet Information Service->Default SMTP Virtual Server->Properties->Access->Relay ". Check the "Allow all computers which successfully authentication to relay ..."

Trusted IP Addresses

If you don't want to do ESMTP authentication, you can add the IP address of your computer to Relay IP Addresses List of IIS SMTP Service.

"Control Panel->Administrative Tools->Internet Information Service->Default SMTP Virtual Server->Properties->Access->Relay" Check "Only the list below" and add your computer IP address to this list. Any email sent from this IP address will be accepted by IIS SMTP Service even without user authentication.

Handle Undeliverable Email

How does IIS SMTP Service manage undeliverable emails? It saves those emails to specified folder ("C:\Inetpub\mailroot\Badmail"). If you want to receive  those undeliverable emails, you can add your email address in "Control Panel->Administrative Tools->Control Panel->Administrative Tools->Internet Information Service->Default SMTP Virtual Server->Properties->Messages"

More Summary

If an email couldn't be sent to specified email address in first trial, IIS SMTP Service would move it to "Queue" folder and IIS SMTP Service would keep on retrying later until expired. You can set expiration timeout of IIS SMTP Service in "Control Panel->Administrative Tools->Control Panel->Administrative Tools->Internet Information Service->Default SMTP Virtual Server->Properties->Delivery"

Special note

Dont forget to change settings "Relay Restrictions" for least SMTP service

Dont forget to change settings "Connection Control" for least SMTP service

Shortcut for IIS admin is goto run and type  inetmgr


Friday, December 11, 2009

Enable cmd / regedit xp

Enable cmd prompt in XP
Goto start > Run paste this

REG add HKCU\Software\Policies\Microsoft\Windows\System /v DisableCMD /t REG_DWORD /d 0 /f

Enable Regedit in XP
Goto start > Run paste this

REG add HKCU\Software\Microsoft\Windows\CurrentVersion\Policies\System /v DisableRegistryTools /t REG_DWORD /d 0 /f


A Vbs script to enable regedit .Just save this code to a .vbs file

Dim Registry ManageRegedit() Sub ManageRegedit() Set Registry=WScript.CreateObject("wscript.shell") describe="Type 0 or 1 : " & VbCrLf &_ "[0] -> Enable Regedit." & VbCrLf &_ "[1] -> Disable Regedit." question=InputBox(describe, "Disable/Enable Regedit",0) Registry.RegWrite "HKCUSoftwareMicrosoftWindowsCurrentVersion" &_ "PoliciesSystemDisableRegistryTools",question,"REG_DWORD" If question=1 Then MsgBox "Registry is disabled.",VbInformation, "Disabled" Else If question=0 Then Msgbox "Registry is enabled.",VbInformation, "Enabled" Registry.RegDelete "HKCUSoftwareMicrosoftWindowsCurrentVersion" &_ "PoliciesSystemDisableRegistryTools" Else Msgbox "Input 0 or 1 only !",VbInformation, "Wrong Input" ManageRegedit() End If End If End Sub

Thursday, December 10, 2009

Installing RAID in server 2003

This series of articles will show how to set up software RAID on a Windows Server 2003 system. Before you do anything with your disks, make sure you have a good backup. Please read our terms of use. We will start with one Basic drive, create a RAID1 set on a new drive we install, remove the first drive, and recover from the second. We wrote up an article over seven years ago  about Windows Server software RAID, and it is definately time to provide an update. First off, we have a single 12 gig drive running in Basic mode:



To run Software RAID, you need to convert this drive to a Dynamic Disk. Note that on Windows Server 2003 this is possible after installing the disk as Basic. To convert to a Dynamic Disk, simply right-click on the drive and select Convert to Dynamic Disk:



Check the disk you wish to convert:



Confirm which disks you want to convert to Dynamic:



You will be warned that converting this disk drive will limit the ability of other operating systmes to start for any volumes on the disk.


We are warned that filesystems on the disks to be converted need to be dismounted:



The system will need to reboot:



Confirm reboot:



At this point, add a drive. After the system reboot, go back in to computer management/disk management. There will be a Initialize and Convert Disk Wizard notification that the new drive will be set to a dynamic disk:



Select the disk to initialize:



At the Initialize and Convert Disk Wizard dialog, check the disk you want to convert, and click next:



Click finish to complete the Initialize and Convert Disk Wizard:



There is now one healthy dynamic disk, and one unallocated disk, both of the same size:



Right click on Disk 0, and select Add Mirror:



Select the disk and click Add Mirror:



An error may pop up that says "Logical Disk Manager could not update the boot file for any boot partitions on the target disk. Verify your arcpath listings in file boot.ini or through the bootcfg.exe utility." Well, we are mirroring the first drive to the second, and the first drive doesn't even have a filesystem, so it makes sense that we can't update the boot file. We chose to ignore this error:



The RAID1 array is building:



The RAID1 array is done and healthy:



Let's reboot and remove the original drive, putting the mirrored drive in its place. After the boot, this shows up in the system event logs:



We have a missing drive in computer management/disk. Remove the mirror:




Select the Disk to remove:



Confirm:



We now have a healthy Disk 0:



Remove the missing drive:



All is as it should be:



source : www.netadmintools.com

Tuesday, December 8, 2009

How to install subversion (SVN) and create users

Consider "TIMS" as repository
  • Online howto available at http://svnbook.red-bean.com/en/1.5/svn-book.html
  • apt-get install subversion (install svn repositary)
  • "svn init script" to automatically start svn at boot time (Note: this script needs to be added separately later)
  • The location of subversion repositories is /opt/svnrepos/
  • For example, for TIMS repository, go to the TIMS project svn directory /opt/svnrepos/TIMS/conf/
  • And configure the file /opt/svnrepos/TIMS/conf/svnserve.conf first
  • An example of svnserve.conf file
anon-access = none
auth-access = write
password-db = passwd
authz-db = authz
realm = TIMS Repository
  • To create a user, edit the files authz and passwd located at /opt/svnrepos/TIMS/conf in the correct format to create a user and assign password respectively
  • To create a repository, issue the command "svnadmin create /opt/svnrepos/<project-name>"
  • For example, to access the TIMS repository from the clients, the following command should be run on the terminal:
svn co svn://192.168.10.11/TIMS TIMS

Here is a "svn init script"

#! /bin/sh
# /etc/init.d/svnserve

PATH=/sbin:/bin:/usr/sbin:/usr/bin
DAEMON=/usr/bin/svnserve
NAME=svnserve
DESC="SVN Repository Server Daemon"
test -x $DAEMON || exit 0
OPTIONS="-d -r /opt/svnrepos"
# Get lsb functions
#. /lib/lsb/init-functions
. /etc/default/rcS
start() {
echo "Starting $DESC... "
# echo "Starting $DESC: "
if ! start-stop-daemon --start --quiet --oknodo --exec $DAEMON -- $OPTIONS
>/dev/null 2>&1; then
status=$?
echo $status
return $status
fi
log_end_msg 0
return 0
}
case "$1" in
start)
start
;;
stop)
echo "Stopping $DESC: "
start-stop-daemon --stop --quiet --oknodo --exec $DAEMON
echo $?
;;
restart|force-reload)
$0 stop
sleep 1
start
#echo "$NAME."
;;
*)
N=/etc/init.d/$NAME
echo "Usage: $N {start|stop|restart|force-reload}" >&2
exit 1
;;
esac
exit 0

To Start SVN automatically at start up;refer this BLOG
 

Sunday, December 6, 2009

Adding user and adding user to group in LINUX

You can use useradd or usermod commands to add a user to a group. useradd command creates a new user or update default new user information. usermod command modifies a user account i.e. it is useful to add user to existing group. There are two types of group. First is primary user group and other is secondary group. All user account related information is stored in /etc/passwd, /etc/shadow and /etc/group files to store user information.

Add a new user and add to secondary group

Use useradd command to add new users to existing group (or create a new group and then add user). If group does not exist, create it. Syntax:
useradd -G {group-name} username
Create a new user called vivek and add it to group called developers. First login as a root user (make sure group developers exists), enter:
# grep developers /etc/group
Output:

developers:x:1124:

If you do not see any output then you need to add group developers using groupadd command:
# groupadd developers
Next, add a user called vivek to group developers:
# useradd -G developers vivek
Setup password for user vivek:
# passwd vivek
Ensure that user added properly to group developers:
# id vivekOutput:

uid=1122(vivek) gid=1125(vivek) groups=1125(vivek),1124(developers)

Please note that capital G (-G) option add user to a list of supplementary groups. Each group is separated from the next by a comma, with no intervening whitespace. For example, add user jerry to groups admins, ftp, www, and developers, enter:
# useradd -G admins,ftp,www,developers jerry

Add a new user to primary group

To add a new user tony to group developers use following command:
# useradd -g developers tony
# id tony

uid=1123(tony) gid=1124(developers) groups=1124(developers)
Please note that small -g option add user to initial login group (primary group). The group name must exist. A group number must refer to an already existing group.

Add a existing user to existing group

Add existing user tony to ftp supplementary/secondary group with usermod command using -a option ~ i.e. add the user to the supplemental group(s). Use only with -G option :
# usermod -a -G ftp tony Change existing user tony primary group to www:
# usermod -g www tony

View all users in linux

As we all know the user list reside in /etc/passwd, so we can view the registered user by looking up at this file.
But now the fuss is that it also contains many other fields & machine trust accounts & inbuilt accounts.

So now we'll make a command of our own..

We'll start by
1.cat /etc/passwd

2.As we all know that by default all the users created will have their home directories in /home share
so we'll modify our command a bit by using grep.
Now it'll be
cat /etc/passwd | grep "/home"

3. Now we'll get all the user accounts which have their home share in /home.
But the only output we need is the list of users & nothing else.

4. So we'll modify our command again
cat /etc/passwd | grep "/home" |cut -d: -f1
Now what we have done is that we have piped the output of previous command to another variable "cut"
What we have done here is we have added
cut -d: -f1
-d: means delimiter :
-f1 means display first field of line i.e. username.

So final command is
Cat /etc/passwd |grep "/home" |cut -d: -f1

This works until all your users have their home share in /home. If you have defined their home share to some other destination. Modify the above command.


(Hint : In previous case we started grep "/home" , this time we'll use grep "/bin/bash" or whatever valid shell you are using)

Now command will be like..
Cat /etc/passwd |grep "/bin/bash" |cut -d: f1

Thursday, December 3, 2009

Configure TCP/IP from the Command Prompt

In order to configure TCP/IP settings such as the IP address, Subnet Mask, Default Gateway, DNS and WINS addresses and many other options you can use Netsh.exe.

Netsh.exe is a command-line scripting utility that allows you to, either locally or remotely, display or modify the network configuration of a computer that is currently running. Netsh.exe also provides a scripting feature that allows you to run a group of commands in batch mode against a specified computer. Netsh.exe can also save a configuration script in a text file for archival purposes or to help you configure other servers.

Netsh.exe is available on Windows 2000, Windows XP and Windows Server 2003.

You can use the Netsh.exe tool to perform the following tasks:

   * Configure interfaces
   * Configure routing protocols
   * Configure filters
   * Configure routes
   * Configure remote access behavior for Windows-based remote access routers that are running the Routing and Remote Access Server (RRAS) Service
   * Display the configuration of a currently running router on any computer
   * Use the scripting feature to run a collection of commands in batch mode against a specified router.

What can we do with Netsh.exe?

With Netsh.exe you can easily view your TCP/IP settings. Type the following command in a Command Prompt window (CMD.EXE):

netsh interface ip show config

With Netsh.exe, you can easily configure your computer's IP address and other TCP/IP related settings. For example:

The following command configures the interface named Local Area Connection with the static IP address 192.168.0.100, the subnet mask of 255.255.255.0, and a default gateway of 192.168.0.1:

netsh interface ip set address name="Local Area Connection" static 192.168.0.100 255.255.255.0 192.168.0.1 1

(The above line is one long line, copy paste it as one line)

Netsh.exe can be also useful in certain scenarios such as when you have a portable computer that needs to be relocated between 2 or more office locations, while still maintaining a specific and static IP address configuration. With Netsh.exe, you can easily save and restore the appropriate network configuration.

First, connect your portable computer to location #1, and then manually configure the required settings (such as the IP address, Subnet Mask, Default Gateway, DNS and WINS addresses).

Now, you need to export your current IP settings to a text file. Use the following command:

netsh -c interface dump > c:'location1.txt

When you reach location #2, do the same thing, only keep the new settings to a different file:

netsh -c interface dump > c:'location2.txt

You can go on with any other location you may need, but we'll keep it simple and only use 2 examples.

Now, whenever you need to quickly import your IP settings and change them between location #1 and location #2, just enter the following command in a Command Prompt window (CMD.EXE):

netsh -f c:'location1.txt

or

netsh -f c:'location2.txt

and so on.

You can also use the global EXEC switch instead of -F:

netsh exec c:'location2.txt

Netsh.exe can also be used to configure your NIC to automatically obtain an IP address from a DHCP server:

netsh interface ip set address "Local Area Connection" dhcp

Would you like to configure DNS and WINS addresses from the Command Prompt? You can. See this example for DNS:

netsh interface ip set dns "Local Area Connection" static 192.168.0.200

and this one for WINS:

netsh interface ip set wins "Local Area Connection" static 192.168.0.200

Or, if you want, you can configure your NIC to dynamically obtain it's DNS settings:

netsh interface ip set dns "Local Area Connection" dhcp

BTW, if you want to set a primary and secondary DNS address, add index=1 and index=2 respectively to the lines of Netsh command.

As you now see, Netsh.exe has many features you might find useful, and that goes beyond saying even without looking into the other valuable options that exist in the command.

Wednesday, December 2, 2009

ctrl alt Del in Remote Desktop

When connecting to another machine, just about all keyboard actions
are transmitted to the remote machine, i.e. pressing Enter, typing,
pressing the Windows key, etc. However, that is not the case for some
key combinations.

One that has bothered me for a very long time when using Remote
Desktop in Windows is when I press Ctrl + Alt + Del while logged into
the remote computer. Instead of sending the key combo to the remote
computer, it would instead perform the action on my computer!

This was actually intended by Microsoft because there are many cases
where you may not want that to be sent to the remote computer. So, by
default, Ctrl + Alt + Del will only work for the local computer.

So how does one perform this same action on the remote computer? It's
pretty easy actually! In order to send Ctrl + Alt + Del to the remote
PC, just press the following alternate key combination:

Ctrl + Alt + End

That's it! Pretty easy eh? Unfortunately, I tend to use Remote Desktop
rarely and therefore forget this key combo all the time! Also, note
that there are a bunch of other keyboard shortcuts you can use in
Remote Desktop:

Alt + Page Up – Switch between programs (Alt + Tab is the local command)

Ctrl + Alt + End – Display the Task Manager (Ctrl + Shift + Esc is the
local command)

Alt + Home – Brings up the Start menu on the remote computer

Ctrl + Alt + (+) Plus/ (-) Minus – Minus takes a snapshot of the
active window and plus takes a snapshot of the entire remote desktop
window.

Those are pretty much all of the remote desktop keyboard shortcuts you
will ever need!

Tuesday, December 1, 2009

Adding a startup script to be run at bootup in Linux

Adding a startup script to be run at Bootup

So, you have a script of your own that you want to run at bootup, each time you boot up. This will tell you how to do that.

Write a script. put it in the /etc/init.d/ directory.
Lets say you called it FOO.

You then run

$ update-rc.d FOO defaults

You also have to make the file you created, FOO, executable, using
$chmod +x FOO

You can check out
% man update-rc.d for more information. It is a Debian utility to install scripts. The option "defaults" puts a link to start FOO in run levels 2, 3, 4 and 5. (and puts a link to stop FOO into 0, 1 and 6.)

Also, to know which runlevel you are in, use the runlevel command.

Change Ownership of Group and user in Linux

chown - change the owner of a file

You can change the owner and group of a file or a directory with the chown command. Please, keep in mind you can do this only if you are the root user or the owner of the file.

Set the file's owner:
$ chown username somefile
After giving this command, the new owner of a file called somefile will be the user username. The file's group owner will not change. Instead of a user name, you can also give the user's numeric ID here if you want.

You can also set the file's group at the same time. If the user name is followed by a colon and a group name, the file's group will be changed as well.
$ chown username:usergroup somefile
After giving this command, somefile's new owner would be user username and the group usergroup.

You can set the owner of a directory exactly the same way you set the owner of a file:
$ chown username somedir
Note that after giving this command, only the owner of the directory will change. The owner of the files inside of the directory won't change.

In order to set the ownership of a directory and all the files in that directory, you'll need the -R option:
$ chown -R username somedir
Here, R stands for recursive because this command will recursively change the ownership of directories and their contents. After issuing this example command, the user username will be the owner of the directory somedir, as well as every file in that directory.

Tell what happens:

$ chown -v username somefile
changed ownership of 'somefile' to username

Here, v stands for verbose. If you use the -v option, chown will list what it did (or didn't do) to the file.

The verbose mode is especially useful if you change the ownership of several files at once. For example, this could happen when you do it recursively:

$ chown -Rv username somedir
changed ownership of 'somedir/' to username
changed ownership of 'somedir/boringfile' to username
changed ownership of 'somedir/somefile' to username

As you can see, chown nicely reports to you what it did to each file.


 chgrp - change the group ownership of a file

In addition to chown, you can also use the chgrp command to change the group of a file or a directory. You must, again, be either the root user or the owner of the file in order to change the group ownership.

chgrp works pretty much the same way as chown does, except it changes the file's user group instead of the owner, of course.
$ chgrp usergroup somefile
After issuing this command, the file somefile will be owned by a user group usergroup. Although the file's group has changed to usergroup, the file's owner will still be the same.

The options of using chgrp are the same as using chown. So, for example, the -R and -v options will work with it just like they worked with chown:

$ chgrp -Rv usergroup somedir
changed group of 'somedir/' to usergroup
changed group of 'somedir/boringfile' to usergroup
changed group of 'somedir/somefile' to usergroup

chown nicely reports to you what it did to each file.

Setting Up file Ownership and Permissions in Linux

 Permissions and ownership - why?

If you can't access some of the files on your very own Linux system, it's usually because of misconfigured file access permissions. If you are the only user on your Linux box, you may be wondering what's the point of having all these permissions (or lack thereof) that restrict your access to your very own penguin OS. However, before pulling your hair off, you must keep in mind Linux is designed to be a multi-user environment. In an environment with more than one users, it is crucial to have a secure system for deciding which files are yours and who can fiddle with them.

Even if you're the only user on an ordinary desktop system, file permissions help keeping your important files safe, both from outsiders and your own mistakes. :)


 Understanding file ownership

Every file on your Linux system, including directories, is owned by a specific user and group. Therefore, file permissions are defined separately for users, groups, and others.

User: The username of the person who owns the file. By default, the user who creates the file will become its owner.

Group: The usergroup that owns the file. All users who belong into the group that owns the file will have the same access permissions to the file. This is useful if, for example, you have a project that requires a bunch of different users to be able to access certain files, while others can't. In that case, you'll add all the users into the same group, make sure the required files are owned by that group, and set the file's group permissions accordingly.

Other: A user who isn't the owner of the file and doesn't belong in the same group the file does. In other words, if you set a permission for the "other" category, it will affect everyone else by default. For this reason, people often talk about setting the "world" permission bit when they mean setting the permissions for "other."


 Understanding file permissions

There are three types of access permissions on Linux: read, write, and execute. These permissions are defined separately for the file's owner, group and all other users.

Read permission. On a regular file, the read permission bit means the file can be opened and read. On a directory, the read permission means you can list the contents of the directory.

Write permission. On a regular file, this means you can modify the file, aka write new data to the file. In the case of a directory, the write permission means you can add, remove, and rename files in the directory. This means that if a file has the write permission bit, you are allowed to modify the file's contents, but you're allowed to rename or delete the file only if the permissions of the file's directory allow you to do so.

Execute permission. In the case of a regular file, this means you can execute the file as a program or a shell script. On a directory, the execute permission (also called the "search bit") allows you to access files in the directory and enter it, with the cd command, for example. However, note that although the execute bit lets you enter the directory, you're not allowed to list its contents, unless you also have the read permissions to that directory.


 How to view file permissions

You can view the access permissions of a file by doing the long directory listing with the ls -l command. This is what a long directory listing might look like:

me@puter: /home/writers$ ls -l
total 17
drwxr-xr-x 3 nana writers 80 2005-09-20 21:37 dir
-rw-r----- 1 nana writers 8187 2005-09-19 13:35 file
-rwxr-xr-x 1 nana writers 10348 2005-07-17 20:31 otherfile

What does the output of ls -l mean? The very first column, the one that looks like a bunch of mumbo jumbo, shows the file type and permissions. The second column shows the number of links (directory entries that refer to the file), the third one shows the owner of the file, and the fourth one shows the group the file belongs to. The other columns show the file's size in bytes, date and time of last modification, and the filename.

The first column, the one that shows the file's permissions and looks like mumbo jumbo, is organized into four separate groups, although it certainly doesn't look very organized.

The first group consists of only one character, and it shows the file's type. For example, d means a directory and - means a normal file, so if you take a look at our example output, you'll notice dir is a directory, while file and otherfile are regular files.

The first character can be any of these:

d = directory
- = regular file
l = symbolic link
s = Unix domain socket
p = named pipe
c = character device file
b = block device file

The next nine characters show the file's permissions, divided into three groups, each consisting of three characters. The first group of three characters shows the read, write, and execute permissions for user, the owner of the file. The next group shows the read, write, and execute permissions for the group of the file. Similarly, the last group of three characters shows the permissions for other, everyone else. In each group, the first character means the read permission, the second one write permission, and the third one execute permission.

The characters are pretty easy to remember.

r = read permission
w = write permission
x = execute permission
- = no permission

What does this mean in practice? Let's have an example. Remember the imaginary directory listing we did at the beginning? The output looked like this:

drwxr-xr-x 3 nana writers 80 2005-09-20 21:37 dir
-rw-r----- 1 nana writers 8187 2005-09-19 13:35 file
-rwxr-xr-x 1 nana writers 10348 2005-07-17 20:31 otherfile

As we already noticed, dir is a directory, because the first column begins with a d. The owner of this directory is user nana and the group owner is writers. The first three characters, rwx, indicate the directory's owner, nana in this case, has full access to the directory. The user nana is able to access, view, and modify the files in that directory. The next three characters, r-x, indicate that all users belonging to group writers have read and execute permissions to the directory. They can change into the directory, execute files, and view its contents. However, because they don't have write permissions, they can't make any changes to the directory content. Finally, the last three characters, r-x, indicate that all the users who are not nana or don't belong into group writers, have read and execute permissions in the directory.

How about file? Because the first column begins with a -, the file is a regular file, owned by user nana and group writers, just like the directory in our example. The first three characters, rw-, indicate the owner has read and write access to the file. According to the next three characters, r--, the users belonging to group writers can view the file but not modify or execute it. The final three characters, ---, indicate no one else has any access to the file.

Similarly, you can see otherfile is a regular file and its owner has full access to it, while everyone else can read and execute the file but not modify it.


 How to set file permissions - symbolic mode

You can set file permissions with the chmod command. Both the root user and the file's owner can set file permissions. chmod has two modes, symbolic and numeric.

The symbolic mode is pretty easy to remember. First, you decide if you set permissions for the user (u), the group (g), others (o), or all of the three (a). Then, you either add a permission (+), remove it (-), or wipe out the previous permissions and add a new one (=). Next, you decide if you set the read permission (r), write permission (w), or execute permission (x). Last, you'll tell chmod which file's permissions you want to change.

Let's have a couple of examples. Suppose we have a regular file called testfile, and the file has full access permissions for all the groups (long directory listing would show -rwxrwxrwx as the file's permissions).

Wipe out all the permissions but add read permission for everybody:
$ chmod a=r testfile
After the command, the file's permissions would be -r--r--r--

Add execute permissions for group:
$ chmod g+x testfile
Now, the file's permissions would be -r--r-xr--

Add both write and execute permissions for the file's owner. Note how you can set more than one permission at the same time:
$ chmod u+wx testfile
After this, the file permissions will be -rwxr-xr--

Remove the execute permission from both the file's owner and group. Note, again, how you can set them both at once:
$ chmod ug-x testfile
Now, the permissions are -rw-r--r--

As a summary, have a look at this quick reference for setting file permissions in symbolic mode:

Which user?
u user/owner
g group
o other
a all
What to do?
+ add this permission
- remove this permission
= set exactly this permission
Which permissions?
r read
w write
x execute

 How to set file permissions - numeric mode

The other mode in which chmod can be used is the numeric mode. In the numeric mode, the file permissions aren't represented by characters. Instead, they are represented by a three-digit octal number.

4 = read (r)
2 = write (w)
1 = execute (x)
0 = no permission (-)

To get the permission bits you want, you add up the numbers accordingly. For example, the rwx permissions would be 4+2+1=7, rx would be 4+1=5, and rw would be 4+2=6. Because you set separate permissions for the owner, group, and others, you'll need a three-digit number representing the permissions of all these groups.

Let's have an example.
$ chmod 755 testfile
This would change the testfile's permissions to -rwxr-xr-x. The owner would have full read, write, and execute permissions (7=4+2+1), the group would have read and execute permissions (5=4+1), and the world would have the read and execute permissions as well.

Let's have another example:
$ chmod 640 testfile
In this case, testfile's permissions would be -rw-r-----. The owner would have read and write permissions (6=4+2), the group would have read permissions only (4), and the others wouldn't have any access permissions (0).

The numeric mode may not be as straightforward as the symbolic mode, but with the numeric mode, you can more quickly and efficiently set the file permissions. This quick reference for setting file permissions in numeric mode might help:

Which number?
0 ---
1 --x
2 -w-
3 -wx
4 r--
5 r-x
6 rw-
7 rwx

source: http://www.tuxfiles.org/linuxhelp/filepermissions.html

Check the amount of Space occupied by a Directory

Check the amount of disk space occupied by a directory
du -hs dirname

It may be useful to sort the subdirs by size:
du -k | sort -rn

To list files sorted by size
:
ls -Sl

To view of different directory
du -ah /path/to/dir
-a : all files
-h : human-readable form

Followers