Archive for the tag 'file'

SBDavid

Viewing file statistics

stat - display file or file system status

The stat command provides a complete rundown of the status of a file on the filesystem:

With no option, `stat’ reports all information about the given files. But it also can be used to report the information of the file systems the given files are located on. If the files are links, `stat’ can also give information about the files the links point to.

root@dell:~# stat hdd
File: `hdd’
Size: 384 Blocks: 8 IO Block: 4096 regular file
Device: 802h/2050d Inode: 1358293 Links: 1
Access: (0644/-rw-r–r–) Uid: ( 0/ root) Gid: ( 0/ root)
Access: 2010-01-10 17:00:07.000000000 +0530
Modify: 2009-08-01 09:08:16.000000000 +0530
Change: 2009-08-01 09:08:16.000000000 +0530

The results from the stat command show just about everything you’d want to know about the file being examined, even down the major and minor device numbers of the device where the file is being stored.

SBDavid

Use of file descriptors

Use of file descriptors

There are three types of I/O, which each have their own identifier, called a file descriptor:

standard input: 0

standard output: 1

standard error: 2

In the following descriptions, if the file descriptor number is omitted, and the first character of the redirection operator is , the redirection refers to the standard output (file descriptor 1).

Some practical examples will make this more clear:

ls > dirlist 2>&1

Will direct both standard output and standard error to the file dirlist, while the command

ls 2>&1 > dirlist

Will only direct standard output to dirlist. This can be a useful option for programmers.

ampersand is used to run a process in the background. Here, it merely serves as an indication that the number that follows is not a file name, but rather a location that the data stream is pointed to.

SBDavid

File protection with chmod

File protection with chmod

chmod 400
file To protect a file against accidental overwriting.
chmod 500 directory To protect yourself from accidentally removing, renaming or moving files from this directory.
chmod 600 file A private file only changeable by the user who entered this command.
chmod 644 file A publicly readable file that can only be changed by the issuing user.
chmod 660 file Users belonging to your group can change this file, others don’t have any access to it at all.
chmod 700 file Protects a file against any access from other users, while the issuing user still has full access.
chmod 755 directory For files that should be readable and executable by others, but only changeable by the issuing user.
chmod 775 file Standard file sharing mode for a group.
chmod 777 file Everybody can do everything to this file.

Checking Postfix file permission/ownership discrepancies

# postfix check

The first line (postfix check) causes Postfix to report file permission/ownership discrepancies.

# egrep ‘(reject|warning|error|fatal|panic):’ /var/log/maillog

The second line looks for problem reports from the mail software, and reports how effective the relay and junk mail access blocks are. This may produce a lot of output. You will want to apply some postprocessing to eliminate uninteresting information.

File permissions for virtual pop inboxes in DirectAdmin

Any domains that you want to use for email (eg: mydomain.com) must be in both the /etc/virtual/domains file and the /etc/virtual/domainowners file.

The directory /etc/virtual/mydomain.com must exist and the files /etc/virtual/mydomain.com/passwd and /etc/virtual/mydomain.com/aliases exist.

File permissions for virtual pop inboxes should be the following below but not applicable with Dovecot/Maildir:

/var/spool/virtual/domain.com 770 username:mail
/var/spool/virtual/domain.com/* 660 username:mail

« Prev - Next »