ubuntu

Shell script: Convert text to lowercase and uppercase

Shell script

s="Hello World!" 

echo $s  # Hello World!

a=${s,,}
echo $a  # hello world!

b=${s^^}
echo $b  # HELLO WORLD!

O/p

By bm on March 23, 2017 | ubuntu | 1 comment
Tags: ,

Ubuntu Install Oracle Java 8

Add repository

sudo add-apt-repository ppa:webupd8team/java

Update

sudo apt-get update

Install Java

 sudo apt-get install oracle-java8-installer

Setting Java environment variables

sudo apt-get install oracle-java8-set-default

chk java version

 java -version

Get installation path

which java

Switching between Oracle Java 8 and Java 7

 sudo update-java-alternatives -s java-7-oracle

Setting Up JAVA_HOME

Edit /etc/profile (sudo nano /etc/profile ) and add the following

export JAVA_HOME=/usr/lib/jvm/java-8-oracle

save the file and execute

source /etc/profile
By bm on October 2, 2016 | ubuntu | A comment?
Tags: , ,

Ubuntu Install LAMP using Tasksel

Tasksel installation

First we need to install Tasksel (Tasksel is a Debian/Ubuntu tool that installs multiple related packages as a co-ordinated “task” onto your system. This program is used during the installation process, but users can also use tasksel at any time.)

open teminal (Ctrl+Alt+T) and execute the command

sudo apt-get install tasksel

 install tasksel

After installing Tasksel open the tasksel

sudo tasksel

tasksel

Move the cursor using arrow key and keep cursor near LAMP server and press space button from keyboard for selection, after selecting you can see a star inside the square bracket  (press the space again for remove selection )

select for install

Press enter key for proceed installation

while installing it will ask for mysql user password and confirm password. Provide password and press enter key to proceed

4-tasksel-mysql-passwordd

5-mysql-confirm-passwordd

You are done with the installation,

You can see a www folder created in /var folder.

Open your browser and type http://localhost you can see a default page.

6-installation-completedd

Now you can create your php files inside /var/www/html (Document root) folder, if you kee the folder outside html folder (/var/www) it will not work.

How to change document root

Open default.conf file (located in /etc/apache2/site-available/000-default.conf) with super user permission

sudo gedit /etc/apache2/sites-available/000-default.conf

7-changing-document-root

You can see the DocumentRoot /var/www/html, this you can change to /var/www (you can set any of your folder as document root just give your folder path after DocumentRoot )

8-changed-defaut-configg

Save this file

create a php file outside html folder (/var/www) and add some content

8-2

Restart apache and test http://localhost/index.php in your browser

9-changed-document-root

By bm on September 25, 2016 | ubuntu | A comment?
Tags: , ,

linux change file/folder ownership

Changing file ownership

$ chown ownername folder/filename

$ chown user1 /myfolder

$ chown mikky file.txt

$ chown -R mikky /myfiles/photos

//change the group of file.
$ chown :game data.txt

//the owner is set to charly followed by a colon and a group ownership is set to game group
$ chown charly:game data.txt

Changing group ownership of a file/folder

chgrp [options] group FSO

 

$ chgrp group_name file_name

 

ref: https://en.wikipedia.org/wiki/Chown

ref : https://en.wikipedia.org/wiki/Chgrp

By bm on May 9, 2016 | ubuntu | A comment?

linux change file/folder permission

Viewing permissions

$ ls -l

Changing permissions

chmod who=permissions filename

eg

$ chmod g=rx filename
$ chmod o=rx filename

//adding write permission
$ chmod g+w filename

//removing write permission
chmod a-w filename

Copying permissions

$ chmod g=u filename

Numeric method

$ chmod xxx filename
$ chmod 755 filename

//recursive
$ chmod -R 777 foldername

Permission Groups :

  • u – Owner
  • g – Group
  • o or a – All Users

Permission Types :

  • r – Read
  • w – Write
  • x – Execute

Binary References

  • r = 4
  • w = 2
  • x = 1
Value Meaning
777 (rwxrwxrwx) No restrictions on permissions. Anybody may do anything. Generally not a desirable setting.
755 (rwxr-xr-x) The file’s owner may read, write, and execute the file. All others may read and execute the file. This setting is common for programs that are used by all users.
700 (rwx——) The file’s owner may read, write, and execute the file. Nobody else has any rights. This setting is useful for programs that only the owner may use and must be kept private from others.
666 (rw-rw-rw-) All users may read and write the file.
644 (rw-r–r–) The owner may read and write a file, while all others may only read the file. A common setting for data files that everybody may read, but only the owner may change.
600 (rw——-) The owner may read and write a file. All others have no rights. A common setting for data files that the owner wants to keep private.
By bm on | ubuntu | A comment?

How to upgrade ubuntu

Take all the update and run update-manager -d from terminal

sudo update-manager -d

uu

By bm on May 6, 2016 | ubuntu | A comment?