Useful Linux Commands
Linux Quick Solutions
- Add Java Home to a User
- How to create a new sudo user and secure with SSH key
- How to config Apache to 301 for HTTP to HTTPS
- No space left on device – Could I be running out of Inodes?
Linux Commands
| Command | Description |
| uname -a | kernal version |
| lsb_release -a | Linux OS description |
| for user in $(cut -f1 -d: /etc/passwd); do crontab -u $user -l; done | show all crontabs for machine |
| passwd | to change the password |
| grep -r word * | Find word in files |
| grep -rin word * | Find word in files not case sensitive & show line in file |
| find / -name ‘iptables.*’ | |
| ps -A | grep java | Find all processes with name java |
| ps -ef | grep java | Find all processes with name java (alternative) |
| find . -type f -exec chmod 664 {} \; | Set All file permission |
| find . -type d -exec chmod 2775 {} \; | Set All directory permission |
| chown -R www-data:www-data *.* | Set All file & directory ownership |
| crontab -e | Edit Crom Jobs |
| df -h | Harddrive space status |
| du -h | See size of directories and total at bottom |
| du -h –max-depth=1 | sort -hr | See size of sub-directories and total at bottom |
| sudo netstat -tulpn | grep LISTEN | See what ports are listening |
| mysqld restart | Restart mysql |
| iptables -n -L -v –line-numbers | IP tables with line numbers |
| iptables -A INPUT -p icmp -s 162.209.9.30 -j ACCEPT | Add line to IP table for DB |
| iptables -D INPUT 4 | Remove IP rule by number |
| rm -rf dirname | Remove directory and all contents (add directory name at end) |
| usermod -a -G www-data james | Add existing user to the www-data group |
| rm -rf mydir | Delete all files without prompt in directory |
| find / -name ‘iptables.*’ -type f -delete | Find all files with name like x and delete |
| rsync -auvtz -e “ssh -p 1853” username@xx.xx.xx.xx:/var/www/test/ /var/www/test/ | Simple rsync command |
| scp /dir/file.txt username@xx.xx.xx.xx:/var/www/test/ | SCP local source to destination remote |
| scp username@xx.xx.xx.xx:/var/www/test/ /local/www/test.txt | SCP remote source TO local destination |
| tar -czvf archive.tar.gz /home/ubuntu –exclude=*.mp4 | Simple zip command with exclude file by type |
| ssh-keygen -R hostname | Remove errant record from known_host |
| find /var/log -name “*.log” -type f -mtime +30 -exec rm -f {} \; | Find files with a .log extension older then 30 days and remove them |
Generally I don’t read article on blogs, but I wish to say that this write-up very forced me to take a look at and do it! Your writing style has been amazed me. Thank you, quite great article.
I simply want to mention I’m new to blogging and truly liked your page. Probably I’m likely to bookmark your site . You actually come with really good articles. Kudos for sharing your blog.
Thank you for sharing!
I simply want to say I’m beginner to blogging and site-building and absolutely liked you’re blog. More than likely I’m likely to bookmark your website . You really have superb stories. With thanks for revealing your web site.
WOW just what I was searchinglooking for. Came here by searching for keywordmeta_keyword