Category Archives: bash

Installing Oracle Java8 in 3 lines


Assumptions

  1. apt-get is installed
  2. You have sudo authority

#add repository from webup8team & install oracle java and set as default

sudo add-apt-repository ppa:webupd8team/java
sudo apt-get update
sudo apt-get install oracle-java8-set-default

If you have other java installed previously, you might want to complete remove them first.

sudo apt-get purge openjdk-\*

There's a long description on how to install Oracle Java on WikiHow if you want to install them from scratch.
Advertisements

Find files and listing details on Linux


One common task that we always have to do relatively often is to find the location of some specific files. Although you may have some clues that those files are located in your current working directory, “.” symbolic link used in the command below, you may have no clue to which sub-folder your files are.

Continue reading Find files and listing details on Linux

value too great for base ?!


So, I wrote a script trying to get it to output the previous month as a number with a leading “0”. The problem arrives as bash complains of some errors.

Initially, my script looked like this

MO=$(date '+%m')
MO2=$((MO-1))
P_MONTH=$(printf "%0*d\n" 2 $MO2);

The last line is there so that I still get a numeric month with a leading zero. However, this for some reasons, gave the error “value too great for base”.

After trying to figure out what it actually means, the base here is the numeric base, which bash thinks number with leading “0” is octal.
So, the solution to fix this is to reassure that the ${MO} variable, which is the numeric Month is a base-10 number.

You can achieve this as follow

MO=$(date '+%m');MO=$((10#$MO))
MO2=$((MO-1))
P_MONTH=$(printf "%0*d\n" 2 $MO2);

Encrypt a few files or folder on OsX


May be you are working on a sensitive data, or just want to secure your personal data on your personal computers. Mac offers the whole hard disk encryption when you install the system, as well as, encryption of your backup through “Time Machine”. However, there are times that you might want to add an extra security to your file. May be you save some of the files to Dropbox or Google Drive, and the file might contain your personal health information that you would not want just anyone to be able to simply read it.

There’s a simple tool in OsX that can help you do this.

zip -e [output.zip] [file-to-be-encrypt]

zip utility will ask you to create a password. The stronger the password. The harder it will be to crack it. However, make sure you will remember the password, too. For this reason, I recommend you to use a password manager, e.g. LastPass is one of an excellent and easy to use tool with several browser integration for both mobile device and personal computer.

Just for the peace of mind. The encryption algorithm in zip might not be very strong. But at least, you save some disk space, and there’s one more extra-security of a password protection that you have to go through before accessing the content of the file.

apt-get error with … for package ‘linux-headers-3.2.0-60’ is missing final newline


linux-headers-3.2.0-60-virtual.list

caused you the problem, do the same! Just delete them (I actually just moved them to “linux-headers-3.2.0-60.list.bak” file).

Flight of ideas

I recently clone a virtual machine image and setting up locally. When trying to install a new package through <code>apt-get</code> in Ubuntu. I ran into a strange problem of “missing final newline” in linux-headers.

Trying to google for solution, I found a page in 2004 mentioning this problem. It suggested that a file in /var/lib/dpkg/info/smbf.list is the cause of the error. So, I tried to locate this file but without any success.

I notice that there is “linux-headers-3.2.0-60.list” and a few other files with similar names in this folder. So, well, why not trying to delete them.

It seems like deleting these files fix the problem and allow apt-get to install the package without any problems. So far the system seems normal. We haven’t allowed any additional access through the server, only deleting a few files that don’t look essential for the OS to run.

Further remove other apt-get unused…

View original post 9 more words