Posts

Showing posts from June, 2017

linux filesystem structure | file types | blocks | inodes | superblock | dumpe2fs | mkfs | partition

Image
Every file under a filesystem has a special number called an inode. The inode is where the OS stores the properties of the file and contains the following information: - The file type such as regular, directory, special, link, socket, pipe, or block device - The owner and group information - The permissions of the file (more on this in Chapter 5, Permissions, Access, and Security) - Date and time on which the file was created and when last changed or read - The file size - The inode contains some other information as well Things that are not available in the inode are the full path and name of the file itself. This is stored in the /proc filesystem under the PID (process ID) of the process that owns the file. The superblock is what ties all of the inodes together on a filesystem . It contains all of the information needed to manage the files. Being very important to the system, most Linux filesystems have a backup copy of the superblock at regular in...

validate bash syntax bash -n script

[root@svn ~]# cat sc.sh #!/bin/bash while [ true ] do ; { date >> file1 sleep 5 } done [root@svn ~]# bash -n sc.sh  sc.sh: line 3: syntax error near unexpected token `;' sc.sh: line 3: `do; {' [root@svn ~]# bash -n scriptname Perhaps an obvious caveat: this validates syntax but won't check if your bash script tries to execute a command that isn't in your path, like  ech hello  instead of  echo hello .

photorec /dev/sdc1 # Recover deleted files

photorec /dev/sdc1 # Recover deleted files from /dev/sdc1. Right now I'm listening to "deleted" mp3s

sed examples

Simple search and replace Detailed examples for  substitute  command will be convered in later sections, syntax is s/REGEXP/REPLACEMENT/FLAGS The  /  character is idiomatically used as delimiter character. See also  Using different delimiter for REGEXP editing stdin $ seq 10 | paste -sd, 1,2,3,4,5,6,7,8,9,10 $ # change only first ',' to ' : ' $ seq 10 | paste -sd, | sed ' s/,/ : / ' 1 : 2,3,4,5,6,7,8,9,10 $ # change all ',' to ' : ' by using 'g' modifier $ seq 10 | paste -sd, | sed ' s/,/ : /g ' 1 : 2 : 3 : 4 : 5 : 6 : 7 : 8 : 9 : 10 Note:  As a good practice, all examples use single quotes around arguments to prevent shell interpretation. See  Shell substitutions  section on use of double quotes editing file input By default newline character is the line separator See  Regular Expressions  section for qualifying search terms for example to distinguish between 'hi', 'this...