Linux

Linux commands

In bash print “hello world”

$ echo "Hello World"

Create directory

$ mkdir testing

Change directory

$ cd testing

List contents inside a directory

$ ls -l

Find logged in user

$ whoami
$ users
$ who
$ w

Find out used disk space in the system by user

$ df -h

Brings the system down immediately

$ halt

Powers off the system using predefined scripts to synchronize and clean up the system prior to shutting down

$ init 0

Reboots the system by shutting it down completely and then restarting it

$ init 6

Shuts down the system by powering off

$ poweroff

Reboots the system

$ reboot

Shuts down the system

$ shutdown

Listing the files

$ ls

Listed files with more information

$ ls -l

List hidden or invisible files

$ ls -a

Create file in Linux

$ vi filename

Display content of a file

$ cat filename

Display file content with line number

$ cat -b filename

Counting words in a file

$ wc filename

Get information about multiple files

$ wc filename1 filename2 filename3

Copying contents from 1 file to another file

$ cp source_file destination_file

Make a copy of existing file

$ cp filename copyfile

Change the name of existing file name

$ mv old_file new_file

Rename the existing file

$ mv filename newfile

Delete a file

$ rm filename

Remove multiple files at a time

$ rm filename1 filename2 filename3

Create symbolic link to a file name

$ ln -s filename symlink

Create hard link to a file name

$ ln filename hardlink

Go to home directory

$ cd ~

Got to user’s home directory

$ cd ~username

Got to last directory

$ cd -