Tuesday, November 16, 2010

Useful Linux Commands

• List files, starting with 'V_20100810' and sort results by most recent
ls -lt V_20100810*

• File monitoring(tail displays the lines and then monitors the file)
tail -f V_20100810_DataAccq.log

• Linux version
cat /etc/*-release

• List files with permission details
ls –l

• Remove a folder with its contents
rm –r –f foldername

• Remove all files in a folder
rm -r -f *

• Shutdown PC
shutdown -h now

• Change the user and/or group ownership of each file-chown
chown newowner filename

chown root:root /backup
setup user and group ownership to root user only for /backup directory

chown root:ftp /home/data/file.txt
Set user user ownership to root user and allow any member of ftp group to access file.txt (provided that they have sufficient read/write rights).

• Change file access permissions such as read, write etc. - chmod
chmod [-r] permissions filenames
• r - Change the permission on files that are in the subdirectories of
the directory that you are currently in.
permission - Specifies the rights that are being granted. Below is the
different rights that you can grant in an alpha numeric format.
filenames - File or directory that you are associating the rights with
Permissions
• u - User who owns the file.
• g - Group that owns the file.
• o - Other.
• a - All.
• r - Read the file.
• w - Write or edit the file.
• x - Execute or run the file as a program.


Numeric Permissions:

CHMOD can also to attributed by using Numeric Permissions:

• 400 read by owner
• 040 read by group
• 004 read by anybody (other)
• 200 write by owner
• 020 write by group
• 002 write by anybody
• 100 execute by owner
• 010 execute by group
• 001 execute by anybody

No comments:

Post a Comment

Thanks for visiting my Blog....Ur comments n suggestions are most valuable for me...Thanks