Linux Ask!

Linux Ask! is a Q & A web site specific for Linux related questions. Questions are collected, answered and audited by experienced Linux users.

Jan 022010
 

How to change file's modification time?

Answer:

1. To see the current file stats, use

# stats test.txt

stat test.txt
  File: `test.txt'
  Size: 25557           Blocks: 56         IO Block: 4096   regular file
Device: ca01h/51713d    Inode: 32714       Links: 1
Access: (0644/-rw-r--r--)  Uid: ( 1001/    user)   Gid: ( 1000/ user)
Access: 2010-01-02 18:53:46.000000000 +0800
Modify: 1970-01-01 17:13:08.000000000 +0800
Change: 2010-01-02 18:53:46.000000000 +0800

2. To change the file's mtime (Modification time), use

touch -m -d '1 Jan 2006 12:34' test.txt

3. To change the file's atime (Last access time), use

touch -a -d '1 Jan 2006 12:34' test.txt

Jan 012010
 

How to install bulk packages using yum with groupinstall?

Answer:

Sometimes, if you forgot to select "Development Tools" during Fedora/CentOS installations, you can add them later by using one command

yum groupinstall "Development Tools"

Which save you a lot of times from installing the needed packages one by one.

To see what options are available for groupinstall, try

yum grouplist

Jan 012010
 

How to mount a NFS share?

Answer:

Assume you have a NFS share /data/shares/music, at server: 192.168.1.5

You can mount the NFS share from another system at /mnt/music (create this directory first), with the command below

sudo mount 192.168.1.5:/data/shares/music /mnt/music

This is just an one-time mount.

If you want to mount permanently, you can edit the fstab

vi /etc/fstab

and input

192.168.1.5:/data/shares/music /mnt/music nfs rsize=8192,wsize=8192,timeo=14,intr

Then run the command to see the effect immediately.

sudo mount /mnt/music

Also try to reboot your system to see if the share can be mounted automatically or not.

Jan 012010
 

How to perform checksum on a file?

Answer:

You can use the md5sum or shasum commands.

Example

#md5sum test.txt

f1d41356dcabb8d8acefed069b22b0da  test.txt
#shasum test.txt

809970aec0109c5464dd36a3a9a5a9e79f838313  test.txt

md5sum is faster if you perform the command on a very large file, but shasum is more secure since the chance of two different files have the same checksum is smaller.

References: