CentOs Command CLI command line interface Linux Web Hosting

We can connect to the CentOS server by using a protocol called SSH. SSH stands for Secure Shell, which is an encrypted way that we can remote login to our server and use Centos command mode. Make your VPS Web Hosting with Domain and WP.

The program SSH into your VPS server is called PuTTY.  PuTTY is a free SSH client that is open source and supported on Windows.


Change My Password  :  CentOS Command passwd

Result System will prompt for new password CLI Display

[root@centos:~]# passwd
Changing password for user root.
New password:
Retype new password:
passwd: password updated successfully


Find Your Current Directory Location : Command pwd

Result System will output the directory that you are in.
CLI Display
[root@centos:~]# pwd
/root


Go To The Root Directory (/) :  CentOS Command cd /

Result We change to the main root directory
CLI Display                                                                                                                      [root@centos:~]# cd /
[root@centos:/]#


List Files  :  CentOS Command ls
Result Lists the files in the current directory
CLI Display

[root@centos:/]# ls
bin dev home media opt root sbin sys
var boot etc lib mnt proc run srv tmp var


Change Directory : CentOS Command cd home
Result System moves us to child folder home
CLI Display

[root@centos:/]# cd home
[root@centos: home]#


Move Up A Directory Level : CentOS Command cd ..
Result System moves us to the parent folder
CLI Display

[root@centos: home]# cd ..
[root@centos:/]#


Sudo before a command, will allow our user, zzuser, to be able to elevate it to higher security privileges to install software and make changes. Sudo runs the command as a super user.


Add a New User : CentOS Command adduser zzuser
Result System sets up user zzuser
CLI Display

[root@centos:/]# adduser zzuser
[root@centos:/]#


Change a User’s Password  : Command passwd zzuser
Result System will prompt for you to set
a new password for user zzuser.
CLI Display

[root@centos:/]# passwd zzuser
New password:
Retype new password:
passwd: all tokens updated successfully


Giving a User Sudo Privileges : CentOS Command visudo
Result System will open the sudoer’s file.
CLI Display
[root@centos:/]# visudo
# This file MUST be edited with
the ‘visudo’ command as root.
#
#
Note: Arrow down the document
#
#
#Allow root to run any commands
anywh..
root ALL=(ALL) ALL


Clearing the Screen : CentOS Command clear
Result System will clear the screen
CLI Display
[root@centos:/]# clear


Logging Out : CentOS Command logout
Result System will close SSH session and
exit PuTTY or logout of a Virtual Machine
CLI Display
[root@centos:/]# logout


CentOs COMMAND SYSTEM STATUS


Checking Uptime : CentOS Command uptime
Result System will display the uptime and load average data
CLI Display
[zzuser@centos:~]$ uptime


Checking Memory Usage :  CentOS Command vmstat
Result System will display the amount of memory free and in use
CLI Display
[zzuser@centos:~]$ vmstat


Checking Users on the Server : CentOS Command w
Result System will display the users on the
server
CLI Display
[zzuser@centos:~]# w


Find Your Current Directory Location : Command pwd
Result System will output the directory that you are in.
CLI Display
[zzuser@centos:~]$ pwd
/home/zzuser


Making a New Directory : Command mkdir documents
Result System will create a child
directory called documents
CLIDisplay
[zzuser@centos:~]$ mkdir documents
[zzuser@centos:~]$


List Files :  CentOS Command ls
Result Lists the files in the current directory
CLI Display                                                                                                     [zzuser@centos:~]# ls                                                                                                                 documents


Change to a Child Directory : Command cd documents
Result Changes to the documents directory
CLI Display                                                                                                    [zzuser@centos:~]$ cd documents
[zzuser@centos: documents]$


Change to User Home Directory : CentOS Command cd
Result Changes to user’s home directory
CLI Display                                                                                                                  [zzuser@centos: documents]$ cd
[tzzuser@centos:~]$


Change Directory Using a Full Path
Command cd /home/zzuser/documents
Result Changes to specified directory CLI                                                 [zzuser@centos:~]$ cd /home/zzuser/documents
[zzuser@centos: documents]$


CREATING AND EDITING FILES WITH NANO CentOS


Nano is a useful text editor for the command line interface (CLI) in Linux systems. Since we are using the CLI, nano is keyboard oriented with control keys.

Creating a file in nano : Command nano notes.txt
Result System launches nano for new file notes.txt
CLI Display                                                                                                    [zuser@centos:~]$ nano notes.txt


Nano command keys: ‘Ctrl’ represents the control ‘Ctrl’ key.
‘Ctrl’ G (F1)  Display this help text
‘Ctrl’ X (F2)  Exit from nano
‘Ctrl’ O (F3)  Write the current file to disk
‘Ctrl’ J (F4)   Justify the current paragraph
‘Ctrl’ R (F5)  Insert another file into the current one                                                              ‘Ctrl’ W (F6)  Search for a string or a regular expression
‘Ctrl’ Y (F7)   Go to previous screen
‘Ctrl’ V (F8)   Go to next screen                                                                                              ‘Ctrl’ K (F9)   Cut the current line and storeit in the cutbuffer
‘Ctrl’ U (F10) Uncut from into the current line
‘Ctrl’ C (F11)  Display the position of the cursor
‘Ctrl’ T (F12)  Invoke the spell checker, if available
M-\ (M-|) Go to the first line of the file
M-/ (M-?) Go to the last line of the file
‘Ctrl’ Y Prev Page      ‘Ctrl’ P Prev Line     ‘Ctrl’ X Exit
‘Ctrl’ V Next Page      ‘Ctrl’ N Next Line


Copy to New File : Command cp notes.txt test.txt
Result System copies notes.txt and
creates a new file, test.txt with the contents.
CLI Display                                                                                                                [zzuser@centos:~]$ cp notes.txt test.txt
[zzuser@centos:~]$


List Files : Command ls
Result Lists the files in the current directory
CLI Display                                                                                                              [zzuser@centos:~]$ls
documents notes.txt test.txt


Move a File : Command mv test.txt documents/test.txt
Result System will open test.txt in nano.
CLI Display                                                                                                     [zzuser@centos:~]$ mv test.txt documents/test.txt
[zzuser@centos:~]$


Change Directory to Documents and List Files
CentOS Command cd documents; ls
Result System will change to documents and list files.
CLI Display                                                                                                     [zzuser@centos:~]$ cd documents; ls
[zzuser@centos: documents]$
test.txt


Using mv to Change File Name
CentOS Command mv test.txt newtest.txt; ls
Result System will change the file name to newtest.txt and list the files in the directory.
CLI Display                                                                                                                  [zzuser@centos: documents]$ mv test.txt newtest.txt; ls                                           newtest.txt


Using rm to Delete a File :  Command rm newtest.txt
Result System will delete newtest.txt
CLI Display
[zzuser@centos: documents]$ rm newtest.txt
[zzuser@centos: documents]$


Delete a Directory : Command rm –r documents
Result System will delete the directory named documents.
CLI Display
[zzuser@centos:~]$ rm –r documents
[zzuser@centos:~]$


CentOs UPDATING THE SERVER


Upgrade Server Packages : Command sudo yum upgrade
Result System will increase the user’s rights, search for an updated list of packages, and look for newer versions.
CLI Display
[zzuser@centos:~]$ sudo yum upgrade
password for zzuser:
Do you want to continue? [Y/n] Y
[zzuser@centos:~]$


CentOsS SETTING UP A WEB SERVER


Installing Apache2 :  Command sudo yum install httpd
Result System will install apache2 and dependent packages to the server.
CLI Display
[zzuser@centos:~]$ sudo yum install httpd
password for zzuser:
Do you want to continue? [Y/n] Y
[zzuser@centos:~]$


Starting Apache2  :  Command sudo service httpd start
Result System will start apache2
CLI Display
[zzuser@centos:~]$ sudo service httpd start
password for zzuser:
[zzuser@centos:~]$


Stop Apache2: sudo service httpd stop
Start Apache2: sudo service httpd start
Restart Apache2: sudo service httpd restart


Go To The HTML Directory : Command cd /var/www/html; ls
Result System will change to the html directory and list the files.
CLI Display
[zzuser@centos:~]$ cd /var/www/html; ls
index.html


Open index.html in nano  Command nano index.html
Result System will load index.html into nano.


Installing MariaDB Server

Command sudo yum install mariadb-server
Result System will install MariaDB Server


Stop MariaDB: sudo service mariadb stop
Start MariaDB: sudo service mariadb start
Restart MariaDB: sudo service mariadb restart


Installing PHP5
Command sudo yum install php php-mysql
Result System will install php5 and
dependencies, along with the mysql
package to talk to the database.
CLI Display
[zzuser@centos:~]$ sudo yum install php php-mysql
password for zzuser:
Is this ok? [Y/n]Y
[zzuser@centos:~]$


Installing Sendmail : Command sudo yum install sendmail
Result System will install sendmail
CLI Display
[zzuser@centos:~]$ sudo yum install sendmail
password for zzuser:
Is this ok? [Y/n] Y
[zzuser@centos:~]$


CentOS

We will be happy to hear your thoughts

      Leave a reply