Visual studio code has built-in support for Node.js, JavaScript and Typescript. It also has extensions support for other languages like C#, C++, Python, PHP and much more. It has advanced features like syntax highlighting, debugging, code refactoring, embedded Git and snippets. Visual studio code is an open source you can use it for free.
Basically we can use below methods to install on ubuntu 20.04.
1. Using snap
2. Using apt repository
3. Manual method
Installing software using snap is very easy so this method is useful for beginners.
Step 1. Most of the packages are available in snap repository so it is easy to install just typing below command
sudo snap install --classic code
Step 2. After installation, you can launch Visual studio code using application launcher.
In this method, We can install using apt repository. Apt repository will be having most of the packages, however we have to add new repository for vs code.
Step 1. Firstly, add repository key using below command.
wget -q https://packages.microsoft.com/keys/microsoft.asc -O- | sudo apt-key add -
Step 2. Now add the repository by typing below command.
sudo add-apt-repository "deb [arch=amd64] https://packages.microsoft.com/repos/vscode stable main"
Step 3. Finally install the package.
sudo apt install code
Step 4. After installation you can launch using application launcher.
In this method, we are going to download the package from official website and install using apt.
Step 1. You can go to the following location https://code.visualstudio.com/docs/?dv=linux64_deb to download the package to your local folder.
Step 2. Once downloaded you can go to the downloaded location and type the below command to install.
sudo apt install ./code_1.47.3-1595520028_amd64.deb
Here we are going to use regular apt command however it will install the local package along with dependencies.
Step 3. Finally after installation, you can launch Visual studio code using application launcher.
Also see.
How to install google chrome on ubuntu 20.04
How to install Anydesk on ubuntu 20.04
MySQL workbench has many features like visual SQL development, visual DB administration, connection management, visual data modeling and even more.
Additionally database migration feature helps you to migrate to MySQL from Microsoft Access, SQLite, Sybase SQL Anywhere, Microsoft Access, Microsoft SQL Server, PostgreSQL and much more. Above all, It is cross platform application which is available for Windows, MacOS and Linux.
It is available in 3 different editions standard, enterprise and community. Community version is open source therefore we can use it for personal and non commercial purpose.
We can install MySQL workbench in 2 different ways.
1. Using apt repository
2. Manual method
Using this method, We can install MySQL workbench from official repository.
Step 1. Download the repo config file from the below url. It will directly take to the download page where you can see ubuntu/debian repository config file.
Browse the following url https://dev.mysql.com/downloads/repo/apt/ and Just press Download.
In the Next page click “No thanks, just start my download.” to download the package to your local directory.
Step 2. Check the file in the download directory and install using the below command. This will actually put MySQL repository urls in apt sources list so that we can install the software.
sudo apt install ./mysql-apt-config_0.8.15-1_all.deb
While installing you will be prompted to choose MySQL version and it will be pre-selected. So select OK option by using down key and hit Enter.
Step 3. Update the apt cache by typing below command.
sudo apt update
Step 4. Now install MySQL workbench from the repository using following command.
sudo apt install mysql-workbench-community
Step 5. Finally, Launch workbench using application launcher.
We can download software directly from the official website and we can install it using following method.
Step 1. Download MySQL workbench software from the below url. This is an official url, So you can directly download the file to your local directory.
Browse the following url https://dev.mysql.com/downloads/workbench/ and choose below options.
» select operating system as “Ubuntu Linux”.
» Select OS version as “Ubuntu Linux 20.04 (x86, 64-bit)”.
» Press Download.
» In the Next page click “No thanks, just start my download.” to download the package to your local directory.
Step 2. Once download completed, you can check the downloaded package and Install using below command. Moreover this command will install package along with dependencies.
sudo apt install ./mysql-workbench-community_8.0.20-1ubuntu20.04_amd64.deb
Step 3. Finally, Launch workbench using application launcher.
See also,
How to install google chrome on ubuntu 20.04
How to install Visual Studio Code on ubuntu 20.04
Most of the current android applications are developed using android studio.
It has many inbuilt features which gives you fast and stable development environment. In addition, It has robust testing framework which supports Multi-display support, Emulators and even more.
Android Studio on ubuntu will gives you best developing experience.
We have few methods to install the software on ubuntu, Here we will see how to install using these 2 methods.
1) Using android-studio repository
2) Using snap
We can install android studio by adding official repository to the sources list.
Step 1. Java JDK package is required for Android studio. So We need to install JDK if not installed already.
sudo apt install openjdk-11-jdk
Step 2. We need to add official repository to the sources list. Therefore, Type the below command to add.
Hit enter when it ask for the confirmation.
sudo add-apt-repository ppa:maarten-fonville/android-studio
Step 3. Now update apt cache.
sudo apt update
Step 4. Now install android studio using apt. So that it will install the software along with dependencies.
sudo apt install android-studio
Step 5. Finally, Launch the software using application launcher.
Once you launch, Just follow the default options in the window if you are beginner.
We can install using snap tool. Usually snap repository would have much latest version than regular apt repository.
Step 1. Similarly, We need to install Java JDK which is required for android studio.
sudo apt install openjdk-11-jdk
Step 2. Now install android studio using snap. This will install software with dependencies similar to apt.
sudo snap install android-studio --classic
Step 3. Finally, Launch the software using application launcher.
Similarly same goes here. Once you launch, Just follow the default options in the window if you are beginner.
See also.
How to install Anydesk on ubuntu 20.04
How to install MySQL workbench on ubuntu 20.04
How to install Visual Studio Code on ubuntu 20.04
Google chrome is cross platform web browser which supports mostly all platforms like Linux, Windows, MacOS, Android, IOS and even more.
It is fast, secure and reliable. In addition, It has many features and large number of extensions to support various functionalities.
But there is a big disadvantage, It consumes more CPU and memory when compared to other popular browsers.
There are many ways to install software on Ubuntu. We will see how to install google chrome using below 2 methods.
1) Using repository
2) Manual method
We can install google chrome by adding chrome official repository url to the sources list. This method is recommended since it will install software along with dependencies.
Step 1. Add chrome repository by using the below command. This command will create a new file with chrome repository details.
sudo bash -c 'echo "deb [arch=amd64] http://dl.google.com/linux/chrome/deb/ stable main" >> /etc/apt/sources.list.d/google-chrome.list'
Step 2. Now add the signing key for the repository.
sudo wget -q -O - https://dl.google.com/linux/linux_signing_key.pub | sudo apt-key add -
Step 3. Update the apt cache so that it will get the package list from the added repository.
sudo apt update
Step 4. Finally, Install google chrome by typing below command.
sudo apt install google-chrome-stable
Step 5. Now you can launch google chrome using application launcher.
In Manual method, We can install after manually downloading the software and install using apt.
Step 1. Download google chrome debian package using below command. Software will be downloaded to the current directory.
wget https://dl-ssl.google.com/linux/direct/google-chrome-stable_current_amd64.deb
Step 2. Check the downloaded file and give execute permission.
user@krizna:~$ ls -l google-*
-rw-rw-r-- 1 user user 66985784 May 2 2020 google-chrome-stable_current_amd64.deb
Give execute permission to install the downloaded file.
chmod +x google-chrome-stable_current_amd64.deb
Step 3. Finally, Install the software using below command. This command will install software with dependencies.
sudo apt install ./google-chrome-stable_current_amd64.deb
Step 4. similarly, you can launch google chrome using launcher.
See Also,
How to install MySQL workbench on ubuntu 20.04
Recently zoom becomes more popular during lockdown. Even it made a headlines because of security bug. Apart from that It is reliable, light weight and cross platform application which supports windows, macOS, Linux, Mobile devices and even more. Like other application, Zoom has both free and paid versions. We can use free version for personal use and host up to 100 participants.
Mostly schools and universities use Zoom to take virtual classes to their students.
Zoom application is not available in ubuntu repository. so we have to download from zoom official site and install it manually.
Step 1. Download the application from the following link https://zoom.us/download?os=linux
Choose “Linux Type” as Ubuntu and version as “14.04+”.
[OR]
Download the software directly using below command. This will download the software to the currect directory.
wget https://zoom.us/client/latest/zoom_amd64.deb
Step 2. Go to the directory where the software was downloaded. Check and provide execute permission.
user@krizna:~$ ls -l zoom_amd64.deb
-rwxrwxr-x 1 user user 41529568 Apr 30 15:01 zoom_amd64.deb
Provide execute permission to avoid errors.
chmod +x zoom_amd64.deb
Step 3. Finally, Install the software using below command. This command will install the software along with dependencies.
sudo apt install ./zoom_amd64.deb
Step 4. After installation, you can launch Zoom using application launcher.
Additionally, you can test zoom application by joining test call using the following link “https://zoom.us/test”
See also
How to install TeamViewer on ubuntu 20.04
How to install Anydesk on ubuntu 20.04
TeamViewer has many additional features like remote printing and file sharing. Also it has remote rebooting, unattended access, Wake-on-LAN and much more features.
TeamViewer is mostly used for remote assistant to customers and employees.
In addition, It has QuickSupport tool which is lightweight client application. It does not require installation or admin access. Therefore, it provides instant remote access for quick assistant.
Basically TeamViewer has both paid and free version. So we can use free version for personal and non commercial purpose.
Step 1. Download teamviewer application for ubuntu from the following link https://www.teamviewer.com/en/download/linux/.
Choose the package for linux and you will find the download link under “Ubuntu, Debian”.
[OR]
Use the below command to download. This command will directly download the software to the current directory.
wget https://download.teamviewer.com/download/linux/teamviewer_amd64.deb
Step 2. Go to the directory where the package is downloaded and give execute permission.
user@krizna:~/Downloads$ ls -l
total 14212
-rw-rw-r-- 1 user user 14551536 Apr 30 19:16 teamviewer_amd64.deb
Provide execute permission so that package can be installed.
chmod +x teamviewer_amd64.deb
Step 3. Now use below command to install the software.
It may require many dependencies. so therefore, system needs to be connected to the internet.
sudo apt install ./teamviewer_amd64.deb
Step 4. Finally, you can launch by typing teamviewer in application launcher.
We have one more software anydesk which is similar to teamviewer .
Here is the guide How to install Anydesk on ubuntu 20.04
See also
How to install Zoom on ubuntu 20.04
How to install MySQL workbench on ubuntu 20.04
Anydesk has many features like file transfer, TCP tunneling, remote sound, clipboard, remote printing and even more. Therefore, It is mostly used by IT support personal to provide remote assistant.
Anydesk is powerful and stable software which has both paid and free version. So for personal use, we can use this software for free.
There are many ways to install Anydesk on ubuntu 20.04. We will follow one of the below methods.
1) Using repository
2) Manual install
Follow the steps as root user to install Anydesk from the repository.
Step 1. Add Anydesk repository key to the Trusted software providers list.
wget -qO - https://keys.anydesk.com/repos/DEB-GPG-KEY | apt-key add -
Step 2. Now add the repository to the sources list.
Below command will put the repository entry in a new file under /etc/apt/sources.list.d/ directory.
* Execute as single command
echo "deb http://deb.anydesk.com/ all main" > /etc/apt/sources.list.d/anydesk-stable.list
Step 3. Update the apt cache by running below command.
apt update
Step 4. Now install the software. This command will download and install Anydesk from repository along with dependencies.
apt install anydesk
Step 5. Finally, You can launch by typing Anydesk in the application launcher.
This method same is similar to previous method. However, we can download the latest software from Anydesk site and install locally.
Step 1. Download the latest Anydesk software from the following link https://anydesk.com/en/downloads/linux using web browser.
[OR]
Use the following command to download latest software.
* Execute as single command
wget $(wget -q -O anydesk https://anydesk.com/en/downloads/linux && grep -Eo "(http|https)://[a-zA-Z0-9./?=_-]*amd64.deb" anydesk | head -1 ) && rm anydesk
Step 2. After that go to the downloaded directory and check the file.
user@krizna:~/Downloads$ ls -l
Give execute permission so that we can install the software.
anydesk_5.5.5-1_amd64.deb
chmod +x anydesk_5.5.5-1_amd64.deb
Step 3. Now install the downloaded software.
This command will install the downloaded package. In addition, It will install the dependencies needed for the software.
sudo apt install ./anydesk_5.5.5-1_amd64.deb
Step 4. Finally, You can launch the application by typing Anydesk in the application launcher.
See also
» How to setup VNC server on centos 8 / RHEL 8
» How to install TeamViewer on ubuntu 20.04
Tigervnc is one of the most popular VNC software available for Centos / RHEL. We can easily install using yum or dnf, since it is available in the default repository.
First of all, We need desktop environment installed on servers in order to setup VNC. Basically all desktop versions will have desktop environment, so you can skip step 2 if you are using desktop version.
Step 1. Let’s start, First update the installed packages to the latest version using below command. Please note it will update most of the packages to latest version so maybe you can skip this step in critical production machines.
[root@krizna ~]# dnf update -y
Step 2. Install GNOME Desktop environment if you are using server version without GUI. This may take some time to complete.
[root@krizna ~]# dnf groupinstall "Server with GUI" -y
Step 3. Edit this file “/etc/gdm/custom.conf” and uncomment following line to disable Wayland.
WaylandEnable=false
Or You can use this command to uncomment the line.
[root@krizna ~]# sed -i 's/#WaylandEnable/WaylandEnable/g' /etc/gdm/custom.conf
Step 4. Type this command to change system to runlevel 5 without rebooting.
[root@krizna ~]# systemctl isolate graphical.target
Step 5. Now install tigervnc package with dependencies.
[root@krizna ~]# dnf install tigervnc-server tigervnc-server-module -y
Step 6. Create an user John for VNC . Also create password and VNC access password for that user.
[root@krizna ~]# adduser john
[root@krizna ~]# passwd john
[root@krizna ~]# su - john
[john@krizna ~]$ vncpasswd
[john@krizna ~]$ exit
logout
Step 7. Create a systemd service file by copying default vncserver@.service, so we can modify and start the service.
cp /lib/systemd/system/vncserver@.service /etc/systemd/system/vncserver@:1.service
vi /etc/systemd/system/vncserver@:1.service
Modify below line (Line no : 29) with the username we created in previous step.
Replace < USER > with john
ExecStart=/usr/bin/vncserver_wrapper <USER> %i
Therefore my file will looks like below
ExecStart=/usr/bin/vncserver_wrapper john %i
Step 8. Run these commands to start and enable vncservice during startup.
We have to reload systemd daemon since we edited/added systemd service file.
[root@krizna ~]# systemctl daemon-reload
Now start the service.
[root@krizna ~]# systemctl start vncserver@:1.service
Enable the service to start automatically during reboot.
[root@krizna ~]# systemctl enable vncserver@:1.service
Step 9. Finally allow VNC service in firewalld.
Get the default zone and add vnc-server to the zone and reload.
[root@krizna ~]# firewall-cmd --get-default-zone
public
[root@krizna ~]# firewall-cmd --zone=public --permanent --add-service=vnc-server
success
[root@krizna ~]# firewall-cmd --reload
success
Step 10. We almost there, Now you can access server using IPaddress with VNCport 5901 (Eg: IPADDRESS:5901 or IPADDRESS:1).
In order to access VNC server we need VNC client software installed in your desktop . Realvnc and TigerVNC are the popular softwares, so we can use any one of them.
In case if you see black screen when connecting VNC, you may try rebooting the server.
You can also create additional user by following step 6 and step 7 . After creating user, create service file as per step 7 and name it as vncserver@:2.service. Therefore you can use IPaddress:5902 or IPaddress:2 to access VNC session created for that user.
Also See:
How to install VNC server on Centos 7
First check the active interfaces on the server using “nmcli con” command
[root@krizna ~]# nmcli con
NAME UUID TYPE DEVICE
ens192 1432ce8b-92c1-4bc2-bdf4-2b13b7c96304 ethernet ens192
ens224 82ec75e5-6efa-3045-86cc-7c00bb2c403d ethernet ens224
Here we have 2 active connections ens192 and ens224. We will see how to assign IP address for ens192 interface using different method.
Nmtui tool is simple text user interface tool which is very easy to use . You can use this method if you are not familiar with editing files or typing commands.
You can use the arrow keys to move forward and hit enter to select the option on the screen.
We are going to use below details for this method.
» Type the “nmtui” command to open nmtui GUI.
[root@krizna ~]# nmtui
» Choose “Edit a connection” and press Enter .
» Here you may see multiple network interfaces connected to the server. so choose the correct interface which you want to configure and press Enter.
» In this screen you will see many options. however, we will use only few.
Select “show” in IPv4 CONFIGURATION and hit Enter. You will see more options now.
» In the next screen select back and hit enter.
» Now choose Quit and hit enter to exit.
» We have assigned the IP address. Now restart the interface using below commands to update the IP address.
[root@krizna ~]# ifdown ens192
[root@krizna ~]# ifup ens192
» Verify the IP address using “ip add show
[root@krizna ~]# ip add show ens192
2: ens192:
link/ether 00:0c:29:e4:8c:de brd ff:ff:ff:ff:ff:ff
inet 192.168.1.10/24 brd 192.168.1.255 scope global noprefixroute ens192
valid_lft forever preferred_lft forever
inet6 fe80::1c37:829:75b0:cfa/64 scope link noprefixroute
valid_lft forever preferred_lft forever
Nmcli tool is a command-line tool installed by default. It is used to create,delete,edit,active and deactivate network connections.
This method is also quite simple to assign the IP address. Follow the steps .
Replace with your IP address and interface name in the following steps.
We are going to use below details for this method.
» Set the interface configuration method to manual.
[root@krizna ~]# nmcli con mod ens192 ipv4.method manual
» Assign the IP address with subnet prefix 24.
[root@krizna ~]# nmcli con mod ens192 ipv4.addresses 192.168.1.2/24
» Set the gateway for the interface.
[root@krizna ~]# nmcli con mod ens192 ipv4.gateway 192.168.1.1
» Assign DNS nameserver IP.
[root@krizna ~]# nmcli con mod ens192 ipv4.dns "8.8.8.8"
» Now restart the interface using below commands to update the assigned IP address.
[root@krizna ~]# ifdown ens192
[root@krizna ~]# ifup ens192
» Verify the IP address using “ip add show
[root@krizna ~]# ip add show ens192
2: ens192:
link/ether 00:0c:29:e4:8c:de brd ff:ff:ff:ff:ff:ff
inet 192.168.1.2/24 brd 192.168.1.255 scope global noprefixroute ens192
valid_lft forever preferred_lft forever
inet6 fe80::1c37:829:75b0:cfa/64 scope link noprefixroute
valid_lft forever preferred_lft forever
On RHEL 8 and Centos 8, Network interface configuration files can be located under /etc/sysconfig/network-scripts/ with file name ifcfg-[interface name]. In our case filename will be ifcfg-ens192.
We are going to use below details for this method.
» Find the interface config file.
[root@krizna ~]# ls /etc/sysconfig/network-scripts/
ifcfg-ens192 ifcfg-ens224
» Here you can see ifcfg-ens192 file is present in that location. Now modify below lines in the file using vi editor.
Final file should looks like below after modification
[root@krizna ~]# vi /etc/sysconfig/network-scripts/ifcfg-ens192
TYPE=Ethernet
PROXY_METHOD=none
BROWSER_ONLY=no
BOOTPROTO=none
DEFROUTE=yes
IPV4_FAILURE_FATAL=no
IPV6INIT=yes
IPV6_AUTOCONF=yes
IPV6_DEFROUTE=yes
IPV6_FAILURE_FATAL=no
IPV6_ADDR_GEN_MODE=stable-privacy
NAME=ens192
UUID=1432ce8b-92c1-4bc2-bdf4-2b13b7c96304
DEVICE=ens192
ONBOOT=yes
IPADDR=192.168.1.3
PREFIX=24
GATEWAY=192.168.1.1
DNS1=8.8.8.8
» Now restart the interface using below commands to update the assigned IP address.
[root@krizna ~]# ifdown ens192
[root@krizna ~]# ifup ens192
» Verify the IP address using “ip add show
[root@krizna ~]# ip add show ens192
2: ens192:
link/ether 00:0c:29:e4:8c:de brd ff:ff:ff:ff:ff:ff
inet 192.168.1.3/24 brd 192.168.1.255 scope global noprefixroute ens192
valid_lft forever preferred_lft forever
inet6 fe80::1c37:829:75b0:cfa/64 scope link noprefixroute
valid_lft forever preferred_lft forever
» Sometimes you may not see the file in that location. In that case, Just create a new file with below content and restart the network using ifup and ifdown commands.
[root@krizna ~]# vi /etc/sysconfig/network-scripts/ifcfg-ens192
TYPE=Ethernet
BOOTPROTO=none
NAME=ens192
DEVICE=ens192
ONBOOT=yes
IPADDR=192.168.1.3
PREFIX=24
GATEWAY=192.168.1.1
DNS1=8.8.8.8
That’s it. All the best.
Also see
How to Setup network on centos 7
1) Install Apache and configure
2) Testing Apache
3) Install MySQL and configure
4) Testing MySQL
5) Install PHP
6) Testing PHP
7) Testing Alltogether
Step 1 » Apache is the most stable and popular web server ( See more Apache ). It is commonly using by web hosting companies all over the world.
We can install Apache using default repository in almost on all ubuntu varients.
So let’s start, Install Apache with below commands. It may prompt for the password since it requires root privileges to install packages.
krizna@leela:~$ sudo apt update
krizna@leela:~$ sudo apt install apache2 -y
Step 2 » By default ufw firewall is enabled on server version, As a result it would blocks all traffic from outside.
So we can allow apache ports in ufw firewall using below command. This will allow 80 and 443 port access.
krizna@leela:~$ sudo ufw app info "Apache Full"
Step 3 » Now try to access http://SERVERIP ( http://192.168.1.10 ) in your web browser. You should able to see default apache page like below.
Step 4 » Once you get apache default page, Start installing MySQL server package using below command.
krizna@leela:~$ sudo apt install mysql-server -y
Step 5 » Above command will just install MySQL server package with all dependencies. So We have to run below command to configure it.
This command will helps you set password length and complexity. Also it helps you to set root password which is blank by default.Additionally you can remove anonymous user, disallow remote root login and Remove test database.
krizna@leela:~$ sudo mysql_secure_installation
Step 6 » Mysql does not allow to use user root for password authentication, since it is using auth_socket authentication method by default. So either we can change auth method for root or we can create new user which would use mysql_native_password method.
Here I prefer second method due to security reason. So use below command to create additional user and test mysql access.
Here we are creating username krizna with password Pass@123.
krizna@leela:~$ sudo mysql -e "CREATE USER 'krizna'@'localhost' IDENTIFIED BY 'Pass@123';"
Step 7 » Finally now test mysql access by using below command with username and password created.
krizna@leela:~$ mysql -u krizna -p Enter password: Welcome to the MySQL monitor. Commands end with ; or \g. Your MySQL connection id is 12 Server version: 5.7.22-0ubuntu18.04.1 (Ubuntu) Copyright (c) 2000, 2018, Oracle and/or its affiliates. All rights reserved. Oracle is a registered trademark of Oracle Corporation and/or its affiliates. Other names may be trademarks of their respective owners. Type 'help;' or '\h' for help. Type '\c' to clear the current input statement. mysql> exit Bye
Step 8 » Most of all already know that PHP is the most popular programming language for making dynamic web pages. It is used by wordpress,Joomla and drupal.
Here use below command to install PHP along with all dependencies.
krizna@leela:~$ sudo apt install php php-mysql -y
Step 9 » PHP installation itself would enable all needed modules in apache so we can directly test PHP. Therefore create a phpinfo.php file in /var/www/html/ directory with below content.
<?php phpinfo(); ?>
Simply run the below to create the file with content.
krizna@leela:~$ sudo sh -c "echo '<?php\nphpinfo();\n?>' > /var/www/html/phpinfo.php"
Step 10 » So now try to access created page http://SERVERIP/phpinfo.php ( http://192.168.1.10/phpinfo.php ) in you web browser. You should able to see page like below.
Step 11 » Finally we setup LAMP server on ubuntu 18.04 . Now we can test Apache,PHP and MySQL together with below code. Purpose of this test is to ensure everything is working good especially MySQL access from PHP.
So create /var/www/html/dbtest.php file with below content. Also replace MySQL username and password with your credentials created in step 6.
<?php $con = mysqli_connect("localhost","krizna","Pass@123"); if (!$con) { die('Could not connect: ' . mysql_error()); } else { echo "Congrats! connection established successfully"; } mysql_close($con); ?>
Step 12 » Now access http://SERVERIP/dbtest.php ( http://192.168.1.10/phpinfo.php ). As a result you should able to see Congrats message if it’s success.
Once you setup LAMP server on ubuntu 18.04 check this article to secure the server.
All the best.
Also see
Setup LAMP server on centos 7
1) Server version.
2) Desktop version.
Step 1. By default server version is configured to use dhcp. You could see below settings in /etc/netplan/50-cloud-init.yaml file or You may have different filename like 01-netcfg.yaml.
Filename and interface name (ens32) may differ on environments Virtual OS and Host OS .
network: ethernets: ens32: addresses: [] dhcp4: true optional: true version: 2
Here ens32 is your network interface name. “dhcp4: true” value shows that dhcp is enabled for ens32 interface.
So if you have dhcp server in your network, you should able to see ipaddress assigned to your server without making any changes.
Step 2. To assign static ipaddress to the server. Get ready with network details like subnet,gateway and DNS servers.
Edit /etc/netplan/50-cloud-init.yaml file with all network details as below.
network: renderer: networkd ethernets: ens32: dhcp4: no dhcp6: no addresses: [192.168.1.10/24] gateway4: 192.168.1.1 nameservers: addresses: [192.168.1.1,8.8.8.8] version: 2
» Here we have disabled both dhcp4 and dhcp6 with no option.
» addresses: line should contains server ipaddress with subnet CIDR Prefix (More about CIDR)
» gateway4: line should contains default gateway.
» nameservers: should contains ipaddresses of primary and secondary DNS.
Please make sure you have added those lines with correct format.
Step 3. Now apply the changes using below command. It would not show any output if it is success.
krizna@leela:~$ sudo netplan apply
krizna@leela:~$
Now check the status by using below command.
krizna@leela:~$ networkctl status ens32 ● 2: ens32 Link File: /lib/systemd/network/99-default.link Network File: /run/systemd/network/10-netplan-ens32.network Type: ether State: routable (configured) Path: pci-0000:02:00.0 Driver: e1000 Vendor: Intel Corporation Model: 82545EM Gigabit Ethernet Controller (Copper) (PRO/1000 MT Single Port Adapter) HW Address: 00:0c:29:0c:ad:a6 (VMware, Inc.) Address: 192.168.1.10 fe80::20c:29ff:fe0c:ada6 Gateway: 192.168.1.1 DNS: 192.168.1.1 8.8.8.8
You could see ip address and other network details assigned to the interface.
Step 4. If something wrong or if you see any error while running above command. Use –debug to see more info.
krizna@leela:~$ sudo netplan apply
Error in network definition //etc/netplan/50-cloud-init.yaml line 12 column 24: expected mapping
krizna@leela:~$ sudo netplan --debug apply
Here we see some format error on line number 12 which needs to be corrected.
** (generate:23310): DEBUG: 18:36:12.980: Processing input file //etc/netplan/50-cloud-init.yaml..
** (generate:23310): DEBUG: 18:36:12.980: starting new processing pass
Error in network definition //etc/netplan/50-cloud-init.yaml line 12 column 24: expected mapping
Step 5. Here we are going to see about setup network on ubuntu 18.04 Desktop version. DHCP is enabled by default in desktop version as well.So if you have dhcp server in your network, you should get able to get the ipaddress assigned to your machine without doing any changes.
To view the settings click network icon at right top corner next to the volume icon and click “wired settings” or “wireless settings” .
Step 6. Now in network window, Click settings icon under wired or wireless and you would see ipaddress in the allocated by dhcp server.
Step 7. To assign static ipaddress, Click IPv4 tab in the same window and choose manual option .
» Enter static ipaddress with subnet mask in CIDR prefix and gateway.
» Under DNS, Put Automatic to off and Enter DNS ipadresses separated with commas.
Step 8. Now click “Apply” and save the changes. Now restart network service by turnoff and on again.
Click settings again and verify your ipaddress.
Also See
]]>First of all we have to install ubuntu desktop and supported packages in order to enable remote desktop on ubuntu server.
So we are going to install ubuntu desktop environment with minimal packages to keeps your server lightweight.
Step 1 » Let’s start. Update the repositories and start installing packages with minimal option. It would take some time to complete.
krizna@leela:~$ sudo apt update
–no-install-recommends key is used to ignore most of all default softwares. So therefore below command only install base packages which is really needed for GUI.
krizna@leela:~$ sudo apt install --no-install-recommends ubuntu-desktop
Step 2 » Now install some additional gnome packages. Most probably these packages will give you best ubuntu look.
krizna@leela:~$ sudo apt install gnome-panel gnome-settings-daemon metacity nautilus gnome-terminal
Step 3 » And finally install vnc4server package.
krizna@leela:~$ sudo apt install vnc4server
Step 4 » Create a backup of the original vncserver file so that you can restore in case of any issues.
krizna@leela:~$sudo cp /usr/bin/vncserver /usr/bin/vncserver.bkp
Step 5 » And now edit /usr/bin/vncserver file as below.
Find this line
"# exec /etc/X11/xinit/xinitrc\n\n".
And add these lines below.
"gnome-session &\n".
"gnome-panel &\n".
"gnome-settings-daemon &\n".
"metacity &\n".
"nautilus &\n".
"gnome-terminal &\n".
Step 5 » Now login as the user and type “vncserver” command to create vnc password and as well as it enables VNC session.
harry@leela:~$ vncserver
You will require a password to access your desktops.
Password:
Verify:
xauth: file /home/harry/.Xauthority does not exist
New 'leela:1 (harry)' desktop is leela:1
Creating default startup script /home/harry/.vnc/xstartup
Starting applications specified in /home/harry/.vnc/xstartup
Log file is /home/harry/.vnc/leela:1.log
Step 6 » So now VNC session is started with session number 1.
You can access using VNC client ( TightVNC ) with ServerIP:sessionnumber ( Ex: 192.168.0.16:1 ) .
Probably you can have multiple sessions by issuing “vncserver” command multiple times and Also you can access using session numbers 192.168.0.16:2, :3 and so on.
In addition we can configure VNC session as services so that it would start sessions automatically while rebooting the server.
Step 7 » Create service file vncharry@1.service under /etc/systemd/system/ and add below lines.
Replace user name with yours.
So if you want multiple sessions, you need to create another file with same content and have another session number vncharry@2.service.
[Unit] Description=Start Harry VNC service at startup After=syslog.target network.target [Service] Type=forking User=harry PAMName=login PIDFile=/home/harry/.vnc/%H:%i.pid ExecStartPre=-/usr/bin/vncserver -kill :%i > /dev/null 2>&1 ExecStart=/usr/bin/vncserver -depth 24 :%i ExecStop=/usr/bin/vncserver -kill :%i [Install] WantedBy=multi-user.target
Step 8 » Start the service and check the status. Before starting the service you must create VNC session password by using “vncserver” or “vncpasswd” command as the user( Refer step 5 ).
krizna@leela:~$ sudo systemctl daemon-reload
krizna@leela:~$ sudo systemctl start vncharry@1.service
Now check the status . It Should be active and running.
krizna@leela:~# sudo systemctl status vncharry@1.service
● vncharry@1.service - Start TightVNC server at startup
Loaded: loaded (/etc/systemd/system/vncharry@1.service; enabled; vendor preset: enabled)
Active: active (running) since Wed 2017-03-29 12:23:18 IST; 3min 47s ago
Process: 2205 ExecStart=/usr/bin/vncserver -depth 24 :%i (code=exited, status=0/SUCCESS)
Process: 2189 ExecStartPre=/usr/bin/vncserver -kill :%i > /dev/null 2>&1 (code=exited, status=2)
Main PID: 2228 (Xvnc4)
CGroup: /system.slice/system-vncharry.slice/vncharry@1.service
‣ 2228 Xvnc4 :1 -desktop leela:1 (harry) -auth /home/harry/.Xauthority -geometry 1024x768 -depth 24 -rfbwait 30000 -rfbauth /home/harry/.vnc/passwd -rfbport 5901 -pn -fp /usr/X
Mar 29 12:23:15 leela systemd[1]: Starting Start TightVNC server at startup...
Mar 29 12:23:15 leela systemd[2189]: pam_unix(login:session): session opened for user harry by (uid=0)
Step 9 » Finally issue below command to make it auto start while reboot.
krizna@leela:~$ sudo systemctl enable vncharry@1.service
Created symlink from /etc/systemd/system/multi-user.target.wants/vncharry@1.service to /etc/systemd/system/vncharry@1.service.
Now the session will be started automatically after the reboot.
» Restart session using service. You can issue stop and start with the same command.
krizna@leela:~$ sudo systemctl restart vncharry@1.service
» In order to kill particular session manually
harry@leela:~$ vncserver -kill :1
Killing Xvnc4 process ID 1137
» You can set custom screen resolution using -geometry 1280×1024
harry@leela:~$ vncserver -geometry 1280x1024
[or]
In the service file edit Execstart line as below
ExecStart=/usr/bin/vncserver -depth 24 -geometry 1280x1024 :%I
As a result remote desktop window is viewed in 1280×1024 resolution.
» You can reset vnc password using vncpasswd command
harry@leela:~$ vncpasswd
Password:
Verify:
That’s it
Have a good day.
Also see :
» Install VNC server on ubuntu 14.04
» Install VNC server on centos 7
» How to install Anydesk on ubuntu 20.04
This article explains about configuration steps for FTP, FTPS and SFTP.
FTP is unsecure since it’s not encrypted. It is highly recommended to use FTPS or SFTP.
Before starting, It is better to assign static IP to the server.
Please make sure you have an internet connection since we need to install package and dependencies from internet.
We are going to use VSFTPD package for FTP which is flexible and easy to manage.
Step 1 » Update the repository and install vsftpd package using below commands.
krizna@leela:~$ sudo apt update
krizna@leela:~$ sudo apt install vsftpd
Step 2 » Copy the original configuration file for a backup.
krizna@leela:~$ sudo cp /etc/vsftpd.conf /etc/vsftpd.conf.bk
1) FTP configuration.
2) Secure FTP ( FTPS ).
3) SFTP configurarion.
Lets do a basic FTP configuration.
Step 3 » Edit /etc/vsftpd.conf file and make the changes as below.
Uncomment below lines.
write_enable=YES
Add below lines at the end of the file. The first line is to keep all non-chroot users jailed.
local_umask=022
chroot_local_user=YES
Other 2 lines are for the passive port range.
allow_writeable_chroot=YES
pasv_min_port=40000
pasv_max_port=40100
Step 4 » Now restart vsftpd service and check the status.
krizna@leela:~$ sudo systemctl restart vsftpd
krizna@leela:~$ sudo systemctl status vsftpd
● vsftpd.service - vsftpd FTP server
Loaded: loaded (/lib/systemd/system/vsftpd.service; enabled; vendor preset: enabled)
Active: active (running) since Sat 2017-02-25 14:32:35 IST; 3min 57s ago
Process: 1955 ExecStartPre=/bin/mkdir -p /var/run/vsftpd/empty (code=exited, status=0/SUCCESS)
Main PID: 1958 (vsftpd)
Tasks: 1 (limit: 512)
Memory: 392.0K
CPU: 39ms
CGroup: /system.slice/vsftpd.service
└─1958 /usr/sbin/vsftpd /etc/vsftpd.conf
Feb 25 14:32:35 leela systemd[1]: Starting vsftpd FTP server...
Feb 25 14:32:35 leela systemd[1]: Started vsftpd FTP server.
Status should be active and running.If the service is failed to start, Troubleshoot yourself by commenting the lines one by one and check the status after service restart.
Step 5 » Now create an user to test FTP server. Use /usr/sbin/nologin shell to limit access.
krizna@leela:~$ sudo useradd -m jack -s /usr/sbin/nologin
krizna@leela:~$ sudo passwd jack
Step 6 » Add “/usr/sbin/nologin” to /etc/shells file to enable login access for the users who uses nologin shell.
krizna@leela:~$ echo "/usr/sbin/nologin" | sudo tee -a /etc/shells
Test your FTP configuration. Try to connect from ftp client.
[root@localhost ~]# ftp 192.168.22.16
Connected to 192.168.22.16 (192.168.22.16).
220 (vsFTPd 3.0.3)
Name (192.168.22.16:root): jack
331 Please specify the password.
Password:
230 Login successful.
Remote system type is UNIX.
Using binary mode to transfer files.
ftp>
FTP connections can be secured by using SSL certificate. We can create self signed SSL certificate using openssl command.
Step 7 » Create new SSL certificate using below command. Here we are going to create 2048 bit RSA certificate with 365 days validity.
krizna@leela:~$ sudo openssl req -x509 -nodes -days 365 -newkey rsa:2048 -keyout /etc/ssl/private/ftps_vsftpd.pem -out /etc/ssl/private/ftps_vsftpd.pem
Step 8 » Now make changes in /etc/vsftpd.conf file to enable and configure SSL. Find and modify below lines as per our certificate location and enable SSL.
rsa_cert_file=/etc/ssl/private/ftps_vsftpd.pem
rsa_private_key_file=/etc/ssl/private/ftps_vsftpd.pem
ssl_enable=YES
Step 9 » Now restart vsftpd service and check the status.
krizna@leela:~$ sudo systemctl restart vsftpd
Step 10 » Try to connect FTP using with TLS/SSL explicit options. This option can be found in Winscp and filezilla tools.
After successful login, You will be able to tranfer data with encrypted.
SFTP uses different protocol, It is more secure than FTP since it uses ssh port for data transfer.
Step 11 » Install OpenSSH package if it is not installed .
krizna@leela:~$ sudo apt-get install openssh-server
Step 12 » Create a new group for SFTP users.
krizna@leela:~$ sudo addgroup ftpaccess
Step 13 » Edit /etc/ssh/sshd_config file and comment the below line.
#Subsystem sftp /usr/lib/openssh/sftp-server
and add these lines at the end of the file.
Subsystem sftp internal-sftp
Match group ftpaccess
ChrootDirectory %h
X11Forwarding no
AllowTcpForwarding no
ForceCommand internal-sftp
Step 14 » Now restart ssh service.**Please perform this step in the console since you may loose SSH connection while doing the service restart.**
krizna@leela:~$ sudo systemctl restart ssh
Step 15 » Create an user with nologin shell and with group ftpacess.
krizna@leela:~$ sudo useradd -m harry -s /usr/sbin/nologin -G ftpaccess
krizna@leela:~$ sudo passwd harry
Perform below steps to chroot users to their home directories.
Step 16 » Modify home directory permission.
krizna@leela:~$ sudo chown root:root /home/harry
Step 17 » Create a directory “upload” inside home directory and modify ownership. This directory can be used to upload files to the server.
krizna@leela:~$ sudo mkdir /home/harry/upload
krizna@leela:~$ sudo chown harry:ftpaccess /home/harry/upload
Now you can connect server using sftp clients.
[root@localhost ~]# sftp harry@192.168.22.16
harry@192.168.22.16's password:
Connected to 192.168.22.16.
sftp> ls
sftp>
That’s it. All the best.
Also see.
» Setup FTP server on ubuntu 14.04
» Setup FTP server on centos 7
How to install Android Studio on ubuntu 20.04
Step 1 » Install necessary samba package and dependencies using below command .
[root@krizna ~]# yum install -y samba samba-client samba-common
and enable the smb and nmb service .
[root@krizna ~]# systemctl enable smb.service
[root@krizna ~]# systemctl enable nmb.service
Step 2 » Choose or Create a directory for shares and allow in SELINUX .
[root@krizna ~]# mkdir /shares
and check the selinux policy status using ls -Z.
[root@krizna ~]# chcon -R -t samba_share_t /shares
[root@krizna ~]# ls -Z /
......
drwxr-xr-x. root root unconfined_u:object_r:samba_share_t:s0 shares
Step 3 » Allow samba service in the firewall and reload service.
[root@krizna ~]# firewall-cmd --permanent --zone=public --add-service=samba
[root@krizna ~]# firewall-cmd --reload
Step 4 » Make a copy of default conf file for backup.
[root@krizna ~]# cp /etc/samba/smb.conf /etc/samba/smb.conf.bkp
Step 5 » Edit /etc/samba/smb.conf file, Find “security = user” line and add “map to guest” line like below.
security = user
map to guest = Bad User
Step 6 » Home directories and printer shares are enabled by default. You can stop those shares by commenting [homes] and [printers] sections in /etc/samba/smb.conf file like below ( optional ).
#[homes] # comment = Home Directories # valid users = %S, %D%w%S # browseable = No # read only = No # inherit acls = Yes #[printers] # comment = All Printers # path = /var/tmp # printable = Yes # create mask = 0600 # browseable = No #[print$] # comment = Printer Drivers # path = /var/lib/samba/drivers # write list = root # create mask = 0664 # directory mask = 0775
There are different types of samba shares. Here we can see about common types
1. Anonymous Share
2. Secured Shares
3. Home directory
Anonymous share allow everyone to access the share without username & password.
Step 1 » Create a directory for anonymous share and change the ownership to nobody to allow anonymous access.
[root@krizna ~]# mkdir /shares/anonymous
[root@krizna ~]# chown -R nobody:nobody /shares/anonymous
Step 2 » Edit /etc/samba/smb.conf file and add these lines at the end of the file .
[Anonymous] path = /shares/anonymous guest ok = yes browsable =yes writable = yes
For read-only access use below code
[Anonymous] path = /shares/anonymous browsable = yes read only = Yes guest only = Yes
Step 3 » Restart smb service .
[root@krizna ~]# systemctl restart smb.service
Step 4 » Now try to access this share in windows machine using \\IPaddress in Run prompt[ Eg: \\192.168.25.15 ]. You will see the share directory like below.
Secured shares are accessible only by valid users with username and password .
Here i have explained with below scenario.
Larry has access to share google and Mark has access to share facebook .
John has access to both shares
We can have a samba group if we want to give access for multiple users.So here we have to create samba group for each share and assign users in that group for access.
Step 1 » Create directory and group for the share name google.
[root@krizna ~]# mkdir /shares/google
[root@krizna ~]# groupadd smbgg
Step 2 » Change ownership and permission for the directory.
[root@krizna ~]# chown -R root:smbgg /shares/google
[root@krizna ~]# chmod -R 0770 /shares/google
Step 3 » Create user larry by adding to the group smbgg in a single command .
[root@krizna ~]# useradd larry -s /usr/sbin/nologin -G smbgg
Create samba password using the below command .
[root@krizna ~]# smbpasswd -a larry
Step 4 » Now edit /etc/samba/smb.conf file and add the below lines at the end for Share “google”.
[Google] comment = Google Share path = /shares/google valid users = @smbgg guest ok = no writable = yes browsable = yes force group = smbgg #### Below lines are to allow user to edit files created by another user create mask = 0660 force create mode = 0660 directory mask = 0770 force directory mode = 0770
Now after restarting the smb service, You can access Google share using larry credentials.
Step 5 » You can create “facebook” share and user Mark in the same way. But make sure you create different group like “smbfb” for Facebook share and add user mark to that group.
Step 6 » For multiple share access create user by adding both the groups to access both shares.
[root@krizna ~]# useradd john -s /usr/sbin/nologin -G smbgg,smbfb
You can share users home directory by just enabling home section in smb.conf.
Step 1 » You can add or enable home section in /etc/samba/smb.conf file that should looks like below .
[homes] comment = Home Directories valid users = %S, %D%w%S browseable = No read only = No inherit acls = Yes
Step 2 » Selinux may prevent write access to home directories. Enable access using below command.
[root@krizna ~]# setsebool -P samba_enable_home_dirs 1
Step 3 » Now restart service.
[root@krizna ~]# systemctl restart smb.service
Now you could access users home directories.
That’s it . Thanks
Also see :
» Setup File server on ubuntu 14.04 ( Samba )
» Installing and configuring samba on centos 6
1. Installing packages
2. Postfix configuration
3. Dovecot configuration
4. User creation
Step 1 » Assign hostname for the server using the below command.
[root@krizna ~]# hostnamectl set-hostname mail.krizna.com
Step 2 » Make a host entry with your IP in /etc/hosts file.
172.27.0.51 mail.krizna.com
Step 3 » Now start installing packages.
[root@krizna ~]# yum -y install postfix dovecot
After package installation continue with postfix configuration.
First create SSL certificate for encryption.
Step 4 » Follow the below steps one by one for creation.
[root@mail ~]# mkdir /etc/postfix/ssl
Leave blank for A challenge password [] value in the below step.
[root@mail ~]# cd /etc/postfix/ssl
[root@krizna ssl]# openssl genrsa -des3 -out server.key 2048
[root@krizna ssl]# openssl rsa -in server.key -out server.key.insecure
[root@krizna ssl]# mv server.key server.key.secure
[root@krizna ssl]# mv server.key.insecure server.key
[root@krizna ssl]# openssl req -new -key server.key -out server.csr
[root@krizna ssl]# openssl x509 -req -days 365 -in server.csr -signkey server.key -out server.crt
Step 5 » Now open /etc/postfix/main.cf file for changes.
Find and uncomment the below lines.
#inet_interfaces = localhost #---> line no 116
#mydestination = $myhostname, localhost.$mydomain, localhost #--> line no 164
and add below lines at the end of the file. change myhostname and mydomain values with yours and home_mailbox value to your desired directory. Here it will store mails in the users home directory (Eg: /home/john/mail ).
myhostname = mail.krizna.com mydomain = krizna.com myorigin = $mydomain home_mailbox = mail/ mynetworks = 127.0.0.0/8 inet_interfaces = all mydestination = $myhostname, localhost.$mydomain, localhost, $mydomain smtpd_sasl_type = dovecot smtpd_sasl_path = private/auth smtpd_sasl_local_domain = smtpd_sasl_security_options = noanonymous broken_sasl_auth_clients = yes smtpd_sasl_auth_enable = yes smtpd_recipient_restrictions = permit_sasl_authenticated,permit_mynetworks,reject_unauth_destination smtp_tls_security_level = may smtpd_tls_security_level = may smtp_tls_note_starttls_offer = yes smtpd_tls_loglevel = 1 smtpd_tls_key_file = /etc/postfix/ssl/server.key smtpd_tls_cert_file = /etc/postfix/ssl/server.crt smtpd_tls_received_header = yes smtpd_tls_session_cache_timeout = 3600s tls_random_source = dev:/dev/urandom
Step 6 » Open /etc/postfix/master.cf file, add the below lines after “smtp inet n – n – – smtpd” line.
submission inet n - n - - smtpd -o syslog_name=postfix/submission -o smtpd_sasl_auth_enable=yes -o smtpd_recipient_restrictions=permit_sasl_authenticated,reject -o milter_macro_daemon_name=ORIGINATING smtps inet n - n - - smtpd -o syslog_name=postfix/smtps -o smtpd_sasl_auth_enable=yes -o smtpd_recipient_restrictions=permit_sasl_authenticated,reject -o milter_macro_daemon_name=ORIGINATING
Now check the configuration using postfix check command.
Step 7 » Now configure Dovecot SASL for SMTP Auth. Open /etc/dovecot/conf.d/10-master.conf file, find “# Postfix smtp-auth” line ( line no:95 ) and add the below lines.
# Postfix smtp-auth
unix_listener /var/spool/postfix/private/auth {
mode = 0660
user = postfix
group = postfix
}
Step 8 » Open /etc/dovecot/conf.d/10-auth.conf file, find “auth_mechanisms = plain” ( Line no: 100 ) and add login to the value like below.
auth_mechanisms = plain login
Step 9 » Postfix configuration is over. Now restart both postfix and dovecot services and enable auto start.
[root@mail ~]# systemctl restart postfix
[root@mail ~]# systemctl enable postfix
[root@mail ~]# systemctl restart dovecot
[root@mail ~]# systemctl enable dovecot
Step 10 » Add the firewall rules to allow 25, 587 and 465 ports.
[root@mail ~]# firewall-cmd --permanent --add-service=smtp
Now start testing connectivity for each ports 25,587 and 465 using telnet and make sure you are getting AUTH PLAIN LOGIN line after issuing ehlo mail.krizna.com command in telnet.
[root@mail ~]# firewall-cmd --permanent --add-port=587/tcp
[root@mail ~]# firewall-cmd --permanent --add-port=465/tcp
[root@mail ~]# firewall-cmd --reload
[root@mail ~]# telnet mail.krizna.com 465
Trying 172.27.0.51...
Connected to mail.krizna.com.
Escape character is '^]'.
220 mail.krizna.com ESMTP Postfix
ehlo mail.krizna.com <------- Type this command
250-mail.krizna.com
250-PIPELINING
250-SIZE 10240000
250-VRFY
250-ETRN
250-STARTTLS
250-AUTH PLAIN LOGIN
250-AUTH=PLAIN LOGIN
250-ENHANCEDSTATUSCODES
250-8BITMIME
250 DSN
Start configuring Dovecot .
Step 11 » Open /etc/dovecot/conf.d/10-mail.conf file, find #mail_location = (line no : 30 ) and add the same directory which is given to home_mailbox in the postfix config file ( Step 5).
mail_location = maildir:~/mail
Step 12 » Open /etc/dovecot/conf.d/20-pop3.conf file, find and uncomment the below line ( line no : 50 ) .
pop3_uidl_format = %08Xu%08Xv
Step 13 » Restart dovecot service.
[root@mail ~]# systemctl restart dovecot
Step 14 » Add firewall rules to allow 110,143,993 and 995.
[root@mail ~]# firewall-cmd --permanent --add-port=110/tcp
[root@mail ~]# firewall-cmd --permanent --add-service=pop3s
[root@mail ~]# firewall-cmd --permanent --add-port=143/tcp
[root@mail ~]# firewall-cmd --permanent --add-service=imaps
[root@mail ~]# firewall-cmd --reload
Check the connectivity for the ports 110,143,993 and 995 using telnet.
Now create user for testing .
Step 15 » Create user with /sbin/nologin shell to restrict login access.
[root@mail ~]# useradd -m john -s /sbin/nologin
[root@mail ~]# passwd john
Mail server is ready now, Configure user in your mail client and test send/receive.
Also see :
» Setup mail server on ubuntu 14.04
» Setup mail server on centos 6
All the best.
Step 1 » Update your repository and install VSFTPD package .
[root@krizna ~]# yum check-update
[root@krizna ~]# yum -y install vsftpd
Step 2 » After installation you can find /etc/vsftpd/vsftpd.conf file which is the main configuration file for VSFTP.
Take a backup copy before making changes .
[root@krizna ~]# mv /etc/vsftpd/vsftpd.conf /etc/vsftpd/vsftpd.conf.org
Now open the file and make changes as below
[root@krizna ~]# nano /etc/vsftpd/vsftpd.conf
Find this line anonymous_enable=YES ( Line no : 12 ) and change value to NO to disable anonymous FTP access.
anonymous_enable=NO
Uncomment the below line ( Line no : 100 ) to restrict users to their home directory.
chroot_local_user=YES
and add the below lines at the end of the file to enable passive mode and allow chroot writable.
allow_writeable_chroot=YES
pasv_enable=Yes
pasv_min_port=40000
pasv_max_port=40100
Step 3 » Now restart vsftpd service and make it start automatically after reboot.
[root@krizna ~]# systemctl restart vsftpd.service
[root@krizna ~]# systemctl enable vsftpd.service
Step 4 » Add FTP service in firewall to allow ftp ports .
[root@krizna ~]# firewall-cmd --permanent --add-service=ftp
[root@krizna ~]# firewall-cmd --reload
Step 5 » Setup SEinux to allow ftp access to the users home directories .
[root@krizna ~]# setsebool -P ftp_home_dir on
Step 6 » Now create an User for ftp access. Here /sbin/nologin shell is used to prevent shell access to the server .
[root@krizna ~]# useradd -m dave -s /sbin/nologin
Now user dave can able to login ftp on port 21 .
[root@krizna ~]# passwd dave
You can filezilla or winscp client for accessing files.
SFTP ( Secure File Transfer Protocol ) is used to encrypt connections between clients and the FTP server. It is highly recommended to use SFTP because data is transferred over encrypted connection using SSH-tunnel on port 22 .
Basically we need openssh-server package to enable SFTP .
Install openssh-server package, if its not already installed.
[root@krizna ~]# yum -y install openssh-server
Step 7 » Create a separate group for FTP access.
[root@krizna ~]# groupadd ftpaccess
Step 8 » Now open /etc/ssh/sshd_config file and make changes as below.
Find and comment the below line ( Line no : 147 ).
#Subsystem sftp /usr/libexec/openssh/sftp-server
and add these lines below.
Subsystem sftp internal-sftp
Match group ftpaccess
ChrootDirectory %h
X11Forwarding no
AllowTcpForwarding no
ForceCommand internal-sftp
Step 9 » Now restart sshd service.
[root@krizna ~]# systemctl restart sshd
Now your SFTP server is configured and ready .
Step 10 » Create user jack with /sbin/nologin shell and ftpaccess group
[root@krizna ~]# useradd -m jack -s /sbin/nologin -g ftpaccess
Now assign root ownership for the home directory for chroot access and modify permission.
[root@krizna ~]# passwd jack
[root@krizna ~]# chown root /home/jack
Create a directory www inside home directory for writing and modify ownership .
[root@krizna ~]# chmod 750 /home/jack
[root@krizna ~]# mkdir /home/jack/www
[root@krizna ~]# chown jack:ftpaccess /home/jack/www
Now jack can use both ftp and sftp services . He can upload files in www directory .
If you are going to use FTP and SFTP together in the same server, you should follow above steps while creating users . For existing users add them to ftpaccess and make below changes.
[root@krizna ~]# usermod dave -g ftpaccess
[root@krizna ~]# chown root /home/dave
[root@krizna ~]# chmod 750 /home/dave
[root@krizna ~]# mkdir /home/dave/www
[root@krizna ~]# chown dave:ftpaccess /home/dave/www
Also see :
» Setup FTP server on ubuntu 16.04
» Setup FTP server on ubuntu 14.04
» Configure ftp server on centos 6
Have a nice day.
]]>Step 1 » Install samba packages after updating repositories
krizna@leela:~$ sudo apt-get update
krizna@leela:~$ sudo apt-get install samba samba-common python-glade2
Everyone can access and store files without username and password .
Step 2 » Create folder for Anonymous share.
krizna@leela:~$ sudo mkdir -p /shares/anonymous
Step 3 » Change the ownership to nobody so that everyone can access and store files in that folder.
krizna@leela:~$ sudo chown nobody:nogroup /shares/anonymous/
Step 4 » Now define values in samba configuration to share /shares/anonymous/ folder. /etc/samba/smb.conf is the main configurion file for samba .
Take a backup before editing that file .
krizna@leela:~$ sudo cp /etc/samba/smb.conf /etc/samba/smb.conf.org
now add the below code at the end of the file to enable share.
krizna@leela:~$ sudo vim /etc/samba/smb.conf
[Anonymous] comment = Anonymous share access path = /shares/anonymous browsable = yes writable = yes guest ok = yes read only = no force user = nobody force group = nogroup
Step 5 » Now restart smbd service .
krizna@leela:~$ sudo service smbd restart
After restarting service . Try to access share from windows client (Goto -> RUN -> \serverIP ) . you could access anonymous share folder without username and password, try to create or copy files to that folder.
Secured shares can be accessed using username and password .Here for example, I’m going to create share project1.
Step 6 » Create a folder for share .
krizna@leela:~$ sudo mkdir -p /shares/project1
Step 7 » Create a new group smbproj1,so that Users added to this group can access project1 share.
krizna@leela:~$ sudo addgroup smbproj1
Step 8 » Modify ownership and permission for the folder.
krizna@leela:~$ sudo chown root:smbproj1 /shares/project1/
krizna@leela:~$ sudo chmod 770 /shares/project1/
Step 9 » Now define values in the configuration file .
krizna@leela:~$ sudo vim /etc/samba/smb.conf
[Project1] comment = Project1 Share path = /shares/project1 valid users = @smbproj1 guest ok = no writable = yes browsable = yes
Step 10 » Now restart smbd service .
krizna@leela:~$ sudo service smbd restart
After restarting service, you could see Project1 share . Additional secured shares can be created in the same way.
Add new user john for accessing project1 share
Step 11 » Create a user john .
krizna@leela:~$ sudo useradd john -s /usr/sbin/nologin -G smbproj1
-s /usr/sbin/nologin : Restricting shell access
-G smbproj1 : Added to smbproj1 group
Step 12 » Create samba password for user john
krizna@leela:~$ sudo smbpasswd -a john
Now user john can access Project1 share. Additional users can be added in the same way.
For existing users use usermod command to add user in smbproj1 group and create samba password using smbpasswd.
krizna@leela:~$ sudo usermod mike -G smbproj1
For accessing multiple shares. Example: dave has access to multiple project groups like smbproj1 and smbproj2.
krizna@leela:~$ sudo usermod dave -G smbproj1,smbproj2
For troubleshooting, Use testparm command
For more info Samba file server guide
That’s it. Have a nice day.
Also see:
Setup file server on centos 7 – Step by step
Before installation, Make sure you have assigned static IP to the server.
Step 1 » Issue the below command to update repository.
krizna@leela:~$ sudo apt-get update
Step 2 » Now install isc-dhcp-server package and dependencies.
krizna@leela:~$ sudo apt-get install isc-dhcp-server -y
Step 3 » After installing, open /etc/default/isc-dhcp-server file and assign interface.
krizna@leela:~$ sudo nano /etc/default/isc-dhcp-server
INTERFACES="eth0"
Step 4 » We need to define below values in dhcpd.conf file located in /etc/dhcp/ directory.
Example scenario:
Network : 192.168.100.0/24
Range : 192.168.100.20 ( Starting IP ) – 192.168.100.100 ( Ending IP )
Gateway : 192.168.100.1
Primary DNS : 192.168.100.5
Sec DNS : 8.8.8.8
Take backup copy before making changes to the original file .Better rename the file and create a new one .
krizna@leela:~$ sudo mv /etc/dhcp/dhcpd.conf /etc/dhcp/dhcpd.conf.org
krizna@leela:~$ sudo nano /etc/dhcp/dhcpd.conf
and add the below code after making changes as per your network values.
# option definitions common to all supported networks... default-lease-time 600; max-lease-time 7200; # If this DHCP server is the official DHCP server for the local # network, the authoritative directive should be uncommented. authoritative; # Use this to send dhcp log messages to a different log file (you also # have to hack syslog.conf to complete the redirection). log-facility local7; subnet 192.168.100.0 netmask 255.255.255.0 { #network range 192.168.100.20 192.168.100.100; # Range option domain-name-servers 192.168.100.5, 8.8.8.8; #Pri DNS , Sec DNS option domain-name "krizna.com"; #Domain name option routers 192.168.100.1; #Gateway option broadcast-address 192.168.100.255; #Broadcast default-lease-time 600; max-lease-time 7200; }
Step 5 » Now start/restart dhcp service using the below command.
krizna@leela:~$ sudo service isc-dhcp-server restart
Sometimes you need to reserve IP to some devices like printers, camera, linux machines etc.
In this case, first you need to find MAC Address of that device and define values in that particular subnet.
For example, Printer with 00:DD:HD:66:55:9B MAC Address has to be assigned with 192.168.100.50 IP. For this, you need to add code like below to that subnet.
subnet 192.168.100.0 netmask 255.255.255.0 { #network - - - - - max-lease-time 7200; host printer-finance { hardware ethernet 00:DD:HD:66:55:9B; fixed-address 192.168.100.50; } host cam-gate { hardware ethernet 00:KK:HD:44:55:22; fixed-address 192.168.100.90; } }
and restart DHCP service.
krizna@leela:~$ sudo service isc-dhcp-server restart
That’s it . All the best
Troubleshooting and more config options
Issue the below command to install GUI on server and cloud editions.
krizna@leela:~$ sudo apt-get install --no-install-recommends ubuntu-desktop
Use –no-install-recommends key to keep GUI minimal. this will skip extra tools and apps and will install only basic desktop environment with few supported tools . Ubuntu desktop users can skip this command .
Step 1 » Start installing below gnome packages which helps VNC to load properly . These packages are required for all editions including ubuntu desktop .
krizna@leela:~$ sudo apt-get install gnome-panel gnome-settings-daemon metacity nautilus gnome-terminal
Step 2 » Now install vnc4server package.
krizna@leela:~$ sudo apt-get install vnc4server
Step 3 » Open /usr/bin/vncserver file and edit as follows . Before editing, make a backup copy.
krizna@leela:~$ sudo cp /usr/bin/vncserver /usr/bin/vncserver.bkp
krizna@leela:~$ sudo nano /usr/bin/vncserver
Find this line ( Line no:57 )
"# exec /etc/X11/xinit/xinitrcnn".
and add these lines like below
"# exec /etc/X11/xinit/xinitrcnn". "gnome-panel &n". "gnome-settings-daemon &n". "metacity &n". "nautilus &n". "gnome-terminal &n".
Step 4 » Now type the command vncserver to start VNC session. you will be prompted for creating new vnc password.
krizna@leela:~$ vncserver
You will require a password to access your desktops.
Password:******
Verify:******
xauth: file /home/boby/.Xauthority does not exist
New 'leela:1 (krizna)' desktop is leela:1
Creating default startup script /home/krizna/.vnc/xstartup
Starting applications specified in /home/krizna/.vnc/xstartup
Log file is /home/krizna/.vnc/leela:1.log
Step 5 » Now you can view your remote desktop using IP address and port ( Eg : 192.168.1.10:1 ).
That’s it, your VNC server is working.
Just like centos and other flavours , you can run VNC server as service in ubuntu.
This is very helpful, as it automatically starts vnc sessions when restarting the server.
Step 6 » Create a file vncserver in /etc/init.d/ directory
krizna@leela:~$ sudo nano /etc/init.d/vncserver
and add the below code .
#!/bin/bash ### BEGIN INIT INFO # Provides: VNCSERVER # Required-Start: $remote_fs $syslog # Required-Stop: $remote_fs $syslog # Default-Start: 2 3 4 5 # Default-Stop: 0 1 6 # Short-Description: Start daemon at boot time # Description: Enable service provided by daemon. ### END INIT INFO unset VNCSERVERARGS VNCSERVERS="" [ -f /etc/vncservers.conf ] && . /etc/vncservers.conf prog=$"VNC server" start() { . /lib/lsb/init-functions REQ_USER=$2 echo -n $"Starting $prog: " ulimit -S -c 0 >/dev/null 2>&1 RETVAL=0 for display in ${VNCSERVERS} do export USER="${display##*:}" if test -z "${REQ_USER}" -o "${REQ_USER}" == ${USER} ; then echo -n "${display} " unset BASH_ENV ENV DISP="${display%%:*}" export VNCUSERARGS="${VNCSERVERARGS[${DISP}]}" su ${USER} -c "cd ~${USER} && [ -f .vnc/passwd ] && vncserver :${DISP} ${VNCUSERARGS}" fi done } stop() { . /lib/lsb/init-functions REQ_USER=$2 echo -n $"Shutting down VNCServer: " for display in ${VNCSERVERS} do export USER="${display##*:}" if test -z "${REQ_USER}" -o "${REQ_USER}" == ${USER} ; then echo -n "${display} " unset BASH_ENV ENV export USER="${display##*:}" su ${USER} -c "vncserver -kill :${display%%:*}" >/dev/null 2>&1 fi done echo -e "n" echo "VNCServer Stopped" } case "$1" in start) start $@ ;; stop) stop $@ ;; restart|reload) stop $@ sleep 3 start $@ ;; condrestart) if [ -f /var/lock/subsys/vncserver ]; then stop $@ sleep 3 start $@ fi ;; status) status Xvnc ;; *) echo $"Usage: $0 {start|stop|restart|condrestart|status}" exit 1 esac
Step 7 » Modify execute permission for the file.
krizna@leela:~$ sudo chmod +x /etc/init.d/vncserver
Step 8 » Create vncservers.conf file in /etc/ directory as stated in service code.
krizna@leela:~$ sudo nano /etc/vncservers.conf
and add the below lines for starting vnc session for the user krizna.
VNCSERVERS="1:krizna" VNCSERVERARGS[1]="-geometry 1024x768"
For additional vnc users.
Login into the user
krizna@leela:~$ su - bobby
Create VNC password by the below command . vncserver command ( step 4) is not required when starting as service .
bobby@leela:~$ vncpasswd
Add user to the file.
Password:
Verify:
VNCSERVERS="1:krizna 2:bobby" VNCSERVERARGS[1]="-geometry 1024x768" VNCSERVERARGS[2]="-geometry 1024x768"
Now user krizna can be accessed using serverip:1 ( 192.168.1.10:1 )and bobby using serverip:2 ( 192.168.1.10:2 ).
Step 9 » Issue the below command to add vncserver service to default runlevels.
krizna@leela:~$ sudo update-rc.d vncserver defaults
Step 10 » Now start/restart the service.
krizna@leela:~$ sudo /etc/init.d/vncserver start
[or]
krizna@leela:~$ sudo /etc/init.d/vncserver restart
All the best.
Also see :
» Enable remote desktop ubuntu 16.04
» How to install Anydesk on ubuntu 20.04
» How to install google chrome on ubuntu 20.04
Before starting phpmyadmin installation, You must setup LAMP server on your centos 7 server. Copy and paste below command in terminal for quick setup . At the end, you need to provide some inputs .
» leave blank for current mysql password.
» provide new password and press enter for the rest.
yum -y install httpd mariadb-server mariadb php php-mysql php-gd php-pear php-mbstring && systemctl start httpd.service && systemctl enable httpd.service && systemctl start mariadb && systemctl enable mariadb && firewall-cmd --permanent --add-service http && systemctl restart firewalld.service && mysql_secure_installation
You can also refer this guide – Install LAMP server on centos 7 for more detailed setup.
By default, centos 7 repository does not contains phpmyadmin package. we need to enable EPEL repository. Find the latest EPEL for centos 7 from EPEL for Centos 7
Step 1 » Download and install epel-release-7-x.noarch.rpm file . or install directly by copying the rpm link.
[root@krizna ~]# rpm -ivh http://epel.mirror.net.in/epel/7/x86_64/e/epel-release-7-1.noarch.rpm
Step 2 » Update repositories by issuing below command .
[root@krizna ~]# yum check-update
Step 3 » Now install phpmyadmin package along with dependencies.
[root@krizna ~]# yum -y install phpmyadmin
Step 4 » After installation, Open /etc/httpd/conf.d/phpMyAdmin.conf file ( Apache config file for phpmyadmin ) and edit as follows.
Find these lines . ( Found 2 times )
# Apache 2.4 <RequireAny> Require ip 127.0.0.1 Require ip ::1 </RequireAny>
Replace with
# Apache 2.4 <RequireAny> # Require ip 127.0.0.1 # Require ip ::1 Require all granted </RequireAny>
Step 5 » Restart Apache service .
[root@krizna ~]# systemctl restart httpd.service
Step 6 » Now open http://serverIP/phpmyadmin in your browser. You can login using root as username and mysql root password.
That’s it . Have a nice day.