Advanced file permissions Linux

Sticky Bit

The sticky bit is set on a directory as a way to prevent users from removing files that they do not own. It is represented by the t over the x position on the other octal as in -rwxrwxrwt or -rwxrwxrwT when the x bit is not set on other.

You can set it by using chmod 1775 or chmod +t

Setgid bit on directory

Linux change permission on all directories within a directory not recursively

You can use the find command from terminal. CD info the directory you wnat to run the command in.

List the folder first to see  that we have the correct ones

sudo find . -maxdepth 1 -type d -ls

If we have a list of the directories we want then we can run 

sudo find . -maxdepth 1 -type d -exec chmod 755 {} \;

To change the permissions on all directories or files in a certain path linux

First we have to use find command to look for either directories of files and then we use the exec command on our find.

To change the permissions on all directories in a certain path

$ sudo find /path/you/want/to/search -type d -exec chmod 775 {} +

To change the permissions on all files  in a certain path

$ sudo find /path/you/want/to/search -type f -exec chmod 775 {} +

To Know what the chmod 775 does go here

Change extension of file type in multiple files in Linux

If your  interested in  converting all higher case "JPG" extensions to lower case "jpg" You could use the command line utility rename like so. CD into directory you want to change. Then

rename -n 's/\.JPG$/\.jpg/' *

Use -n option to test what will be changed, then when you happy with results use without like so

rename  's/\.JPG$/\.jpg/' *

List directory size one folder deep in human-readable form Linux

To list all the directories in a folder by size without  giving all subfolders, a nice clear list with no clutter use

$ du --max-depth 1 -h

du  = estimate file space usage

--max-depth 1 = only go 1 deep in the tree

-h = human-readable

For example

Add text to .avi or mpeg4 video files on Ubuntu 12.04

In order to add text to a video file first we need to make sure we have all the editing tools and codecs


sudo apt-get install ubuntu-restricted-extras

sudo apt-get install ffmpeg x264

sudo apt-get install frei0r-plugins mjpegtools


Once all these are installed we can add text by running the command below

Restart Networking Ubuntu Linux

If using ifconfig eth0 down and up on ubuntu it wont renew the IP from the DHCP server. For this we need to restart the network manager.

To restart the networking service in ubuntu in order to get new IP from DHCP

sudo service network-manager stop

sudo service network-manager start


Linux Permissions

Linux permissions are set for three groups on each file or folder. The three groups are Owner, Group and World. If I open a terminal and type;

ls -la

Create a Concateneted Volume

Initialize the disk or partition for use by the Logical Volume Manager LVM

pvcreate /dev/sdb1 /dev/sdb2 /dev/sdb3 /dev/sdb4

Create a volume group

vgcreate myvg /dev/sdb1 /dev/sdb2

Create a logical volume in an existing volume group

lvcreate --size 1g myvg (creates /dev/myvg/lv01

Build the file system ext4 on our new logical volume /dev/myvg/lv01

mkfs -t ext4 /dev/myvg/lv01

Software Packages

To list all of the packages installed on you system

rpm -qa

Different flavors of linux have different package managers that do a lot of the backgroung work like installing dependencies.

SuSe uses zypper

To install a package named nmap

zypper in nmap

To search for a package using zypper

zypper se nmap

Where is the package installed

which nmap



Subscribe to RSS - linux-advanced