This can be achieved using the command nohup
nohup <command> <args> ><filename> 2>&1 & e.g. nohup /usr/bin/terminator -m -T 'main_terminal' -l My_Layout > /dev/null 2>&1 &
This can be achieved using the command nohup
nohup <command> <args> ><filename> 2>&1 & e.g. nohup /usr/bin/terminator -m -T 'main_terminal' -l My_Layout > /dev/null 2>&1 &
>> Exclude .txt files [! CASE SENSITIVE] $ rsync -avz --exclude '*.txt' source/ destination/ >> Exclude from file list $cat exclude-list.txt *.JPG *.TMP *.PDF *.jpg *.tmp *.pdf *.zip relative/path1/ relative/path2/ $ rsync -avz --exclude-from 'exclude-list.txt' /source/path/ /dest/path/ | tee rsync-report.txt >> Exclude directory $ rsync -avz --exclude 'folder1_within_source' --exclude 'folder2_within_source/subfolder2' source/ destination/
>> Create a screen session (labelled) screen -R 'myscreen' >> Detach screen ctrl+A (hold them) + D >> Check current screen sessions screen -ls >>Re-attach screen session screen -r <screen name, from screen -ls including the PID> e.g. screen -r 4238.myscreen >> Quit session screen -X -S [session # you want to kill] quit ======================================= >> When it gets badly stuck screen -ls | grep pts | cut -d. -f1 | awk '{print $1}' | xargs kill screen -ls | grep Attached | cut -d. -f1 | awk '{print $1}' | xargs kill ref: http://askubuntu.com/questions/356006/kill-a-screen-session
Example
# rsync -av --no-perms --no-owner --no-group --chmod=Du=rwx,Dg=rx,Do=rx,Fu=rw,Fg=r,Fo=r /source/path/ username@IP:/destination/path (remove -v if it's in a CRON)
>> disable exclude kernel* in /etc/cron.conf yum search --showduplicates kernel yum list --showduplicates kernel >> install the correct one and re-comment the exclusion.
This is an example where you install Lsyncd on a CentOS master server and you sync the folder ‘data’ on a slave server with IP 10.0.0.3
First of all, your master server needs an SSH key setup AND the slave has to have it configured, to allow passwordless SSH connection
Here an article that tells you how to do it.
/etc/lsyncd.conf
-- comments with "--" settings { logfile = "/var/log/lsyncd/lsyncd.log", statusFile = "/var/log/lsyncd/lsyncd-status.log", statusInterval = 20 } sync { default.rsync, source="/data/", target="10.0.0.3:/data/", rsync = { compress = true, archive = true, verbose = true, rsh = "/usr/bin/ssh -p 22 -o StrictHostKeyChecking=no" }, -- excludeFrom = "/etc/lsyncd.exclusions" }
Add the service and enable it
chkconfig --add lsyncd chkconfig lsyncd on
On CentoS7 use this:
systemctl enable lsyncd.service
Once installed, you also need to be sure that Lsyncd logs are managed by Logrotate.
Create/update this file: /etc/logrotate.d/lsyncd
/var/log/lsyncd/*log { missingok notifempty sharedscripts postrotate if [ -f /var/lock/lsyncd ]; then /sbin/service lsyncd restart > /dev/null 2>/dev/null || true fi endscript }
On CentOS7, you need to use sistemctl instead service command:
/var/log/lsyncd/*log { missingok notifempty sharedscripts postrotate if [ -f /var/lock/lsyncd ]; then /bin/systemctl restart lsyncd.service > /dev/null 2>/dev/null || true fi endscript }
You can test this using the command:
logrotate -d /etc/logrotate.d/lsyncd
For more advanced Lsyncd configuration, check this article 🙂
Pretty basic, but handy for whoever start playing with Linux.
Here simple steps to follow in order to have box1 to be able to connect securely to box2 over SSH without being required to insert password.
This is very handy if you run scripts 😉
On BOX1
You can run this as any user.
ssh-keygen -b 1024 -t rsa -f id_rsa -P ""
This will generate ~/.ssh/id_rsa (private key) and ~/.ssh/id_rsa.pub (public key).
The .pub is the key that needs to be appended in ~/.ssh/authorized_keys on BOX2.
If the following command is available, that’s the best/safest way to setup BOX2.
ssh-copy-id user@box2
Password for user on box2 will be requested.
Once completed, you can try to ssh user@box2 and theoretically you should be able to connect without need to insert the password again!
If ssh-copy-id does not exist (e.g. Mac or other Distros), you can scp the .pub file and append it as per below:
scp ~/.ssh/id_rsa.pub user@box2:/tmp
Then connect to box2 with user and run this:
cat /tmp/id_rsa.pub >> ~/.ssh/authorized_keys rm -f /tmp/id_rsa.pub
After those 2 commands, the key should be added to the authorised ones, so ssh user@box2 should work.
NOTE: if you are experiencing issues, please make sure that the permissions of id_rsa file is 600 on BOX1 and that sshd_conf on BOX2 is set to allow key auth connections
This shows loads of information like Sysinfo in Windows
dmidecode -t system dmidecode -t memory dmidecode -t memory | grep "Maximum Capacity"
If you want to run vim without executing a customer’s .vimrc, as they’ve got crazy colours and random stuff all over the show, just do use NONE as a special value to skip any .vimrc parsing;
vim -u NONE
You might need to run :set nocp in vim itself if you’re like me and used to the non-vi compatible features.
grep -Fxv -f first-file.txt second-file.txt
Basically looks for all lines in second-file.txt which don’t match any line in first-file.txt. Might be slow if the files are large.