Category Linux

Linux/Unix: How to manipulate or change the last modified/accessed time of a file using touch command?

Assume there’s a file @ /home/user/testmsg.txt If you want to change the file timestamp to 09/20/2011 08:30 using touch command, here’s how you can do it: From Wikipedia, touch is a standard Unix program used to change a file‘s access and modification timestamps. It is also used to create a new empty file. Related articles […]

ulimit: How to permanently set kernel limits in Linux?

ulimit provides control over the resources available to the shell and to processes started by it, on systems that allow such control. Usually, you have to increase the values of some of the Linux kernel limits before your install or run many applications. With ulimit you can set two kind of limits: 1. Soft limit: […]

Getting started with Java’s ProcessBuilder: A simple utility class to interact with Linux from Java program

JDK 5.0 adds a new way of executing a command in a separate process, through a class called ProcessBuilder. You can find ProcessBuilder in the java.lang package (like Runtime and Process). According to the docs, This class is used to create operating system processes.Each ProcessBuilder instance manages a collection of process attributes. The start() method […]

How to get the last modified time of a file in Linux?

While I was writing a shell script, I needed the last modified time of a particular file before doing something, and here’s what I used: stat -c ‘%Y’ /root/directory/file.txt This command will give you the last modified time of a file in seconds (since Epoch).