Bash

chown to current cPanel user by path

Use this script file to chown into the cPanel user defined by the path. #!/bin/bash THISUSER=`pwd | cut -d’/’ -f 3` echo echo CHOWN all files to $THISUSER; echo find -exec chown $THISUSER:$THISUSER {} \; chown :nobody /home/$THISUSER/public_html For example, if the path is /home/username/this/file path, this will chown username. Notice that the /home/username/public_html folder actually belongs to the nobody group or you will get errors. We have to use find instead of chown directly…

Continue reading

Bash

su to current cPanel user by path

Use this script file to su into the cpanel user defined by the path. #!/bin/bash THISUSER=`pwd | cut -d’/’ -f 3` echo echo now running as $THISUSER; echo su $THISUSER -s /bin/bash This is a easy option if you need to work on files as the correct owner. For example, if the path is /home/username/this/file path, you will su as username. Installation cat > ~/suthis.sh

Continue reading

Bash

Change the colour scheme in VIM

Dark Blue on black with a bit of light around can make comments really hard to read in VIM. The solution is to change the colour scheme. Within VIM command, just type :colorscheme elflord And all of the colours will change to the “morning” colour scheme. There are quite a few available to choose from. To make this change permanent, add the line into the ~/.vimrc file. echo colorscheme elflord >> ~/.vimrc done

Continue reading

Bash Linux

Redirection Output in Linux Bash/Shell

You can redirect outoput from a command into a file cat filename filename2 and that will redirect all output. But you can also select the type of output 0 = Standard Input 1 = Standard Output 2 = Standard Error So that this wil send error messages to nothing cat filename 2/dev/null Or explicitly send both standard output and standard error to a file with and ampersand (“&”) docommand &filename You can append to a…

Continue reading

Bash Linux SSH

Set up a server to auto login with authorized_keys

You need to create your keys and store them in your personal .ssh folder. cd ~/.ssh ssh-keygen -f filename -C ‘Some comment’ -N ” -t rsa -q You will have two files; id_rsa id_rsa.pub It is the .pub file that you need to copy to the same folder on the target server. scp ~/.ssh/id_rsa.pub server:~/.ssh/authorized_keys You can actually have multiple keys in the same authorized_keys file – just append the new key to the end…

Continue reading

Bash

Change the Linux Bash prompt

To change the Linux Bash prompt to a different format, simply set the PS1 variable PS1=”new prompt text” There are several options that you can use to show different things Switch Purpose \u current User \h short Hostname – up to the first “.” \H full Hostname \w current full path \W current directory \d the date in in “Weekday Month Date” format \t the current time in 24-hour HH:MM:SS format \T the current time…

Continue reading