Blog ยป Linux Commands

Linux Commands

Delete all directories more than a week or X days old

If you are taking the backup via script, you may need to delete your old backups on regular basis to avoid disk space issue. The following command will remove directories from “/home/mydirectory/” which are older more than a month: for i in `find /home/mydirectory/ -maxdepth 1 -type d -mtime +30 -print`; do echo -e “Deleting …

Delete all directories more than a week or X days old Read More »

How to use rsync for custom SSH port

By default rsync uses SSH port 22 while transferring the files/folders between two servers. If you are using custom SSH port instead of default port 22, you will need to add additional flag in rsync command as follow: rsync -avz -e “ssh -p YOUR_SSH_PORT” user@SERVERADDRESS:/home/test /home/abc/ For more rsync option, you can use the following …

How to use rsync for custom SSH port Read More »

How To Start/Restart/Stop iptables and auto start at boot

You can use the following commands to start/restart/stop iptables on your Linux server: To start iptables: service iptables start To stop iptables: service iptables stop To restart iptables: service iptables restart You can determine whether iptables is running or not using following command: service iptables status If “service” command doesn’t work, you can use the …

How To Start/Restart/Stop iptables and auto start at boot Read More »