Showing posts with label linux. Show all posts
Showing posts with label linux. Show all posts

Friday, 31 October 2014

Linux: Change permissions recursively of only directories or only files

For directories:

find /path/to/folder -type d -exec chmod 755 {} \;

For files:

find /path/to/folder -type f -exec chmod 644 {} \;

Another way:

find /path/to/base/dir -type d -exec chmod 755 {} +
find /path/to/base/dir -type f -exec chmod 644 {} + 

http://superuser.com/questions/91935/how-to-chmod-755-all-directories-but-no-file-recursively

However, this seems to be the best solution, when you do not need to unset execute permissions on files:


chmod -R u+rwX,go+rX,go-w /path
The important thing to note here is that X acts differently to x - the man page says The execute/search bits if the file is a directory or any of the execute/search bits are set in the original (unmodified) mode. In other words, chmod u+X on a file won't set the execute bit; and g+X will only set it if it's already set for the user.

Monday, 16 June 2014

cPanel: Install php-devel

CPanel disables installation of php related packages using yum. To enable it:

nano /etc/yum.conf

Remove php* from the "exclude" line.

EPEL repositories for Fedora and Cent OS

Certain applications such as incron can't be found in the default repositories of Cent OS. To get this software, you need to enable the EPEL (Extra Packages for Enterprise Linux) repository:

https://fedoraproject.org/wiki/EPEL#How_can_I_use_these_extra_packages.3F

http://www.rackspace.com/knowledge_center/article/installing-rhel-epel-repo-on-centos-5x-or-6x

Thursday, 5 December 2013

Using at and crontab

http://www.cyberciti.biz/tips/howto-shutdown-linux-box-automatically.html

List of all users and groups

To view all users:

cat /etc/passwd | cut -d: -f1


To view all groups:

cat /etc/group |cut -d: -f1

Thursday, 21 November 2013

Location of php.ini

In the terminal type

php --ini

To view the locations and names of all the ini files that were parsed.

Cloning a disk on Linux

https://wiki.archlinux.org/index.php/Disk_Cloning

Create a tar archive preserving all attributes

tar --selinux --acls --xattrs  -cvf file.tar /var/www
 
http://www.cyberciti.biz/faq/linux-tar-rsync-preserving-acls-selinux-contexts/ 

Wednesday, 20 November 2013

Backup entire installed OS

sudo rsync -aAXv /* /mnt/backup_vol --exclude={/dev/*,/proc/*,/sys/*,/tmp/*,/run/*,/mnt/*,/media/*,/lost+found}


The above command will backup all the OS files with the regular attributes and SELinux attributes. rsync also allows the backups to updated. The backup path should be to a Linux filesystem.

To restore the OS from the backup, and more details see: https://wiki.archlinux.org/index.php/Full_System_Backup_with_rsync

Create tar archive and exclude files and directories

http://stackoverflow.com/questions/984204/shell-command-to-tar-directory-excluding-certain-files-folders

Linux: How to create a filesystem in a file

There are two steps. One should create a large empty file. Then that file should be partitioned and formatted.

To create the empty file on a Linux filesystem, use fallocate:


fallocate -l 10G path/to/file/image.img


This won't work in non-Linux file systems such as FAT32. For those you can used the dd command to create a file full of zeroes.

dd if=/dev/zero of=/path/to/file/image.img -bs=10M -count=20480


The above command will create a 200gb file. The calculation is 204800 / 10 = 20480. The block size should be the size of the storage device's buffer. The speed of creation of the file depends on the size of the block size.

After creating the file, the filesystem should be created. mke2fs will give a warning but you can proceed after entering 'y'.

mke2fs -t ext4 /path/to/file


To mount the filesystem of the file, create a directory in the /mnt directory, and then mount it using the mount command. The filesystem won't show up as a device in the file manager but will function as a separate filesystem when you navigate to the mount directory.

sudo mkdir /mnt/backup_vol
sudo mount -o loop /path/to/disk_image /mnt/backup_vol


The filesystem can be accessed from /mnt/backup_vol

To unmount the filesystem:

sudo umount /mnt/backup_vol


Reference: http://freecode.com/articles/virtual-filesystem-building-a-linux-filesystem-from-an-ordinary-file

Monday, 11 November 2013

Disable selinux temporarily

sudo setenforce 0

To check the status of selinux:

/usr/sbin/getenforce


Thursday, 7 November 2013

Monday, 28 October 2013

Google Chrome proxy setting with command line

/opt/google/chrome/google-chrome --proxy-server=192.168.42.101:8080

Friday, 25 October 2013

Formatting a usb drive

sudo fdisk -l

to find all the filesystems and storage devices

sudo umount /dev/sdb1

to unmount the device sdb1

sudo mkfs.vfat /dev/sdb1

to format as fat 32

Tuesday, 22 October 2013

Thursday, 5 September 2013

To open a port permanently in Fedora 19:

sudo firewall-cmd --zone=public --permanent --add-port=80/tcp

Check if port is open

To check if a port is open:

http://www.yougetsignal.com/tools/open-ports/

Tuesday, 6 August 2013

Linux: Check Ram Speed and Type
$ sudo dmidecode --type 17