Tuesday, May 31, 2016

How to find recently modified files on Linux

To find the most recently modified files, sorted in the reverse order of update time (i.e., the most recently updated files first):

$ find /etc -type f -printf '%TY-%Tm-%Td %TT %p\n' | sort -r

To search for files in /target_directory and all its sub-directories, that have been modified in the last 60 minutes:

$ find /target_directory -type f -mmin -60 This is very handy especially when looking for an error on a system.

Thursday, November 3, 2011

How to set different permissions for subfiles and subdirectories

To give different permission settings for all subdirectories and subfiles use following commands:

find /start/location/ -type f -print0 | xargs -0 chmod 644
find /start/location/ -type d -print0 | xargs -0 chmod 755

If you receive such an error "permission denied", run above commands as root with "su" parameter or try them as following:

sudo find /start/location/ -type f -print0 | sudo xargs -0 chmod 644
sudo find /start/location/ -type d -print0 | sudo xargs -0 chmod 755

In here permission settings of all subfiles will be changed to "644" and all subdirectories will be changed to "755".

Saturday, July 9, 2011

Some useful Linux commands & tips

1) List users with cat or awk in a system
cat /etc/passwd | cut -d: -f 1,3,6 | grep "[5-9][0-9][0-9]" | grep "/home" | cut -d: -f1
awk -F: '$6 ~ /\/home/ && $3 >= 500 {print $1}' /etc/passwd

2) Count the results with the pipe wc -l
Above commands can be rewritten as following
cat /etc/passwd | cut -d: -f 1,3,6 | grep "[5-9][0-9][0-9]" | grep "/home" | cut -d: -f1 | wc -l
awk -F: '$6 ~ /\/home/ && $3 >= 500 {print $1}' /etc/passwd | wc -l

3) Grep command
Recursively search "some_string" only in python files in home directory
grep -r --include="*.py" "some_string" /home
Display the process containing "some_string"
ps aux | grep "some_string"

Thursday, June 9, 2011

Reverse Engineering: Developing a device driver for Linux

Reverse engineering is the most used way to develop a device driver for Linux. If you are interested to write a program to support your unknown driver in Linux, at least you need an average programming capability in C language.

Some useful links:

Introduction to Reverse Engineering Software
www.acm.uiuc.edu/sigmil/RevEng

Learning how to reverse engineer a Windows USB driver
www.jespersaur.com/drupal/book/export/html/21


Processing: Web-cam capturing in Linux

Processing is an open source and cross-platform programming language and integrated development environment (IDE). It is especially used for teaching the basics of computer programming.
Website:
http://processing.org

To capture a web-cam with processing there is a standard video library.
However it requires pre-installation of Quicktime and WinVDIG.

It seemed quite difficult for me to run this way video capturing in Linux.
Finaly I found an additional library GSVideo.
Website:
http://gsvideo.sourceforge.net

It works very similar to the standard video library. Plus it does not require pre-installation of Quicktime & WinVDIG, and works in Linux platform as well.

Below simple example shows the differences of standard video library and GSVideo library.



// Capturing web-cam with standard video library.
// It requires pre-installation of QuickTime and WinVDIG.
// Hard to use in Linux platform.

import processing.video.*;
Capture camera;

void setup(){
size(320, 240);
camera = new Capture(this, 320, 240, 12);
}

void draw(){
image(camera, 0, 0);
}

void captureEvent(Capture camera){
camera.read();
}



// Capturing with GSVideo library works cross-platform.
// It only requires additional GSVideo library as below directory order;
// <processing>/sketchbook/libraries/GSVideo
// Visit gsvideo.sourceforge.net for reference information.

import codeanticode.gsvideo.*;
GSCapture camera;

void setup(){
size(320, 240);
camera = new GSCapture(this, 320, 240);
camera.play();
}

void draw(){
image(camera, 0, 0);
}

void captureEvent(GSCapture camera){
camera.read();
}



It worked very well for me.
Hope this post helps someone else in similar case :)


Friday, June 3, 2011

Display or print Japanese fonts within a pdf file in Ubuntu/Linux Distribution

I had a problem to display/print Japanese fonts in a pdf file in my Ubuntu 10.04 distro. Evince did not display nor print the Japanese fonts. Adobe Reader displayed correctly however it did not print the Japanese fonts.

Installing the package poppler-data fixed those problems. It is available in Ubuntu package manager.

Prior of installing the package poppler-data, I realized that Foxit PDF reader was already rendering the Japanese fonts very well. Therefore I also recommend installing Foxit PDF Reader.

Foxit Reader for Linux:
http://www.foxitsoftware.com/pdf/desklinux/download.html


Monday, January 24, 2011

Choppy Flash playback in full screen [Ubuntu/Linux]

Try these commands:

sudo mkdir /etc/adobe
echo "OverrideGPUValidation=true" >~/mms.cfg
sudo mv ~/mms.cfg /etc/adobe/

Restart the browser.

If that doesn't work, then right-click the flash video, select "Settings", then untick the option "Enable hardware acceleration".

Sources:
http://www.webgapps.org/flash/issues-and-solutions
https://bugs.launchpad.net/ubuntu/+bug/346289