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 -
Get current full path
$ pwd
List the files in a directory
$ ls dirname
$ ls /usr/local
Create multiple directory
$ mkdir docs pub
Remove directory
$rmdir dirname
Remove multiple directory
$rmdir dirname1 dirname2 dirname3
Change directory
$ cd dirname
Rename directory
$ mv olddir newdir
Add execute permission of the owner
$ chmod u+x file
Remove write permission from the group
$ chmod g-w file
Set others to read-only (wipes other permissions)
$ chmod o=r file
Give everyone read and write access
$ chmod a+rw file
Add execute permissions for both owner and group
$ chmod ug+x file
Give all permissions
$ chmod 777
Owner can edit, others can run
$ chmod 755
Owner can edit, others can only read
$ chmod 644
Only owner can read/write
$ chmod 600
Read only for owner
$ chmod 400
Change ownership of a file
$ chown user filelist
Changing owner of the file
$ chown amrood testfile
Changing group of the file
$ chgrp developers testfile
Assing a String in a variable and print
$ MESSAGE="I LOVE JESUS"
$ echo $MESSAGE