Ubuntu Commands

Check Ubuntu Version

lsb_release -a
No LSB modules are available.
Distributor ID:	Ubuntu
Description:	Ubuntu 16.04.6 LTS
Release:	16.04
Codename:	xenial

Display the current Hostname

hostnamectl

//Output

   Static hostname: ubuntu-s-2vcpu-4gb-blr1-01
         Icon name: computer-vm
           Chassis: vm
        Machine ID: 100ea3ee1d0242bab544b3cff195093b
           Boot ID: 36c993753f7a498bb8883b949e5e7949
    Virtualization: kvm
  Operating System: Ubuntu 18.04.2 LTS
            Kernel: Linux 4.15.0-51-generic
      Architecture: x86-64

List the users logged in on the machine.

who

List all users logged in on your network. The rwho service must be enabled for this command to work.

rwho -a

List all Directories and files

ls

Change Directory

cd 
cd /  //To navigate into the root directory 
cd ~  //To navigate to your home directory 
cd .. //To navigate up one directory level 
cd -  //To navigate to the previous directory

Print working directory, i.e. Display the name of your current directory on the screen.

pwd

Print the name of the the machine on which you are working.

hostname´╗┐

Print your login Name.

whoami

Copy File or Directory

The cp command will make a copy of a file for you. Example: “cp file foo” will make an exact copy of “file” and name it “foo”, but the file “file” will still be there.

cp FILENAME

If you are copying a directory, you must use “cp -r directory foo” (copy recursively).

cp -r directory DIRECTORYNAME

Move File or Directory

The mv command will move a file to a different location or will rename a file. Below Code will rename the file “foo” to “bar”

mv foo bar

Below code will move the file “foo” to your Desktop directory, but it will not rename it. You must specify a new file name to rename a file.

mv foo ~/Desktop

Create a New Directory

mkdir Command used to create a new directory.

mkdir DIRECTORYNAME

Remove or Delete File Or Directory

rm Command to remove or delete a file in your directory.

rm FILENAME

rmdir command will delete an empty directory

rmdir DIRECTORYNAME

To delete a directory and all of its contents recursively, use below command

rm -r DIRECTORYNAME
uname -a

//Output FOR 64 Bit Ubuntu
Linux YOURSYSTEMNAME 4.15.0-45-generic #48~16.04.1-Ubuntu SMP Tue Jan 29 18:03:48 UTC 2019 x86_64 x86_64 x86_64 GNU/Linux

uname -i

//Output
x86_64

Leave a Reply

Your email address will not be published. Required fields are marked *