Linux

How to mount a Samba Share on Linux

H

mount -t cifs -o username=YOURUSERNAME,password=YOUPASSWORD //server_name_or_ip/folder_to_mount /mnt/folder_to_mount_to/ By using the above command and by replacing the relevant fields with your details, you should be able to mount your Samba Share on Linux Explanation: mount = mounts a filesystem -t = Used to indicate the filesystem type, in this case cifs cifs = Common Internet Filesystem...

How to solve You have old files in your logwatch tmpdir (/var/cache/logwatch)

H

Edit /etc/logwatch/conf/logwatch.conf and override the TmpDir value by changing the default temp directory to /tmp from /var/cache/logwatch
/tmp automatically gets trimmed by most Linux distributions meaning that there won’t be a built up of old log files.
Now delete the old files in /var/cache/logwatch using the command below:

rm -rf /var/cache/logwatch/*

How to set your default editor in Linux

H

Edit the .bash_profile file in your home directory

vi ~/.bash_profile

Add the following lines to your .bash_profile file

export VISUAL=vim
export EDITOR="$VISUAL"

Note: Replace vim with any other preferred editor such as nano

Logout and login again for changes to take effect.
If you want the changes to come into play immediately, execute the following command

. ~/.bash_profile

How Do I Block an IP Address on Centos 6 via IPTables

H

Open a new Terminal Window Type the following command replacing IPADDRESSTOBLOCK with the IP Address that you wish to block. iptables -A INPUT -s IPADDRESSTOBLOCK -j DROP Explanation of above command: -A = Append one or more rules to the end of the selected chain -s = Source, in this case the IP address to block -j = This indicates what to do if the rule matches Save the Rule to the IPTables...

How to set the default Java version on Linux

H

Open a new Terminal Window Execute the following command: sudo update-alternatives --config java Output similar to the below will show: There are 4 choices for the alternative java (providing /usr/bin/java). Selection Path Priority Status ------------------------------------------------------------ 0 /usr/lib/jvm/java-8-oracle/jre/bin/java 1092 auto mode * 1 /usr/lib/jvm/java-7-openjdk...

How to iterate through an array in a Bash Shell Script

H

Create a new Bash Shell Script eg. loopThroughArray.sh Open the Script with an Editor eg. GEdit Add the array definition through which the script should iterate array=( one two three four five ) The expression ${array[@]} contains all values within the array ${array[@]} Now we create a for loop to iterate through the array   for num in ${array[@]}   do   echo $num   done   Once...

About Author

Ian Carnaghan

I am a software developer and online educator who likes to keep up with all the latest in technology. I also manage cloud infrastructure, continuous monitoring, DevOps processes, security, and continuous integration and deployment.

Follow Me