Note : Most command might require root permission, so type "sudo" before the command.
System Specs from Command Line
==========================
For HD capacity:
$df -h
or
$sudo fdisk -l
For RAM memory:
$free -m
For the linux version rou're on:
$uname -a
For cpu's info
$sudo lshw -class cpu
CPU Number of cores:
$grep -c ^processor /proc/cpuinfo
==========================
For HD capacity:
$df -h
or
$sudo fdisk -l
For RAM memory:
$free -m
For the linux version rou're on:
$uname -a
For cpu's info
$sudo lshw -class cpu
CPU Number of cores:
$grep -c ^processor /proc/cpuinfo
To switch between system directories
=========
$sudo cd /path
Print working directory
=============
$sudo pwd
=============
$sudo pwd
Display current directory information
==========
==========
>List current directory files,size and permissions
$sudo ls -lh
//Permission will be in format: rgu
[directory-root permission(r)-group permission(g)-local user(u)]
Access will be in order-rwx
[read(r),write(w),execute(x)]
$sudo ls -lh
//Permission will be in format: rgu
[directory-root permission(r)-group permission(g)-local user(u)]
Access will be in order-rwx
[read(r),write(w),execute(x)]
Change file permissions
=====================
chmod is used to change permission
=====================
chmod is used to change permission
>Format
$sudo chmod permission filename
Or
$sudo chmod permission directory
$sudo chmod permission filename
Or
$sudo chmod permission directory
>Permissions
Root-r,Group-g,User-u
Read-r,Write-w,Execute-x
+ To add permission and - to remove
Root-r,Group-g,User-u
Read-r,Write-w,Execute-x
+ To add permission and - to remove
>Example
$sudo chmod gu+rw filename //read write permission for group and local user
$sudo chmod r+rwx filename //full root permission
$sudo chmod u+r filename
$sudo chmod u-rwx filename
$sudo chmod gu+rw filename //read write permission for group and local user
$sudo chmod r+rwx filename //full root permission
$sudo chmod u+r filename
$sudo chmod u-rwx filename
>Number mode
Three numbers to represent permissions of root grup and usr
4+2+1(read+write+execute)
Three numbers to represent permissions of root grup and usr
4+2+1(read+write+execute)
$sudo chmod -R 761 filename //full permission to root,read write for group and execute permtn for local user
$sudo chmod -R 777 filename //full permission
How to install an application
========================
>Advance packaging tool(apt) is used to install application through linux terminal.
========================
>Advance packaging tool(apt) is used to install application through linux terminal.
Update command is used before app installation to update the applist index,w hich helps to install the latest updates available.
$sudo apt-get update
$sudo apt-get install app_name
$sudo apt-get install app_name
How to open a text file
================
>For small files
$sudo cat /filepath/filename
================
>For small files
$sudo cat /filepath/filename
>For big files
$sudo less /filepath/filename
$sudo less /filepath/filename
>Another method
$sudo vim /filepath/filenname
$sudo vim /filepath/filenname
>To view first n lines of file
// 0 to show entire file
$sudo head -n -7 filename
// 0 to show entire file
$sudo head -n -7 filename
>To see last n lines of file
$sudo tail -n 7 filename
$sudo tail -n 7 filename
>or
$sudo nano filename
$sudo nano filename
>or
$sudo vi filename
$sudo vi filename
>Or
$sudo gedit filename
$sudo gedit filename
How to open a file in gui
=================
Goto file directory and type
=================
Goto file directory and type
$sudo xdg-open file_name
How to find a particular file
==========
$sudo find -iname 'file_name'
==========
$sudo find -iname 'file_name'
Access remote host in same network
========
We can use secure shell(ssh) or tellnet for accessing host. Tellnet is having less security compared to SSH, intruders can easily acces data. While ssh is secure enough
========
We can use secure shell(ssh) or tellnet for accessing host. Tellnet is having less security compared to SSH, intruders can easily acces data. While ssh is secure enough
>Login to remote host
$sudo ssh -L login_id hostname
Or
$sudo ssh -L login_id ip_address
//Port number might be required in some cases
//Port number might be required in some cases
Search for a string in file or directory
========
>Search for a given string in a file.
========
>Search for a given string in a file.
$sudo grep -i "the" demo_file
//String is case sensitive
>Print the matched line, along with the 5 lines after it.
>Print the matched line, along with the 5 lines after it.
$sudo grep -A 5 -i "example" text_file
>Search for a given string in a directory
$sudo grep -r "ramesh" *
Tar file
======
Similar to Rar file in windows Tar is compressed file format in Linux
======
Similar to Rar file in windows Tar is compressed file format in Linux
>Create a new tar archive.
$sudo tar cvf archive_name.tar dirname/
>Extract from an existing tar archive.
$sudo tar xvf archive_name.tar
>View an existing tar archive.
$sudo tar tvf archive_name.tar
Power options
=============
>Shutdown
$sudo shutdown -h now
=============
>Shutdown
$sudo shutdown -h now
>Shutdown after 10 minute
$sudo shutdown -h +10
$sudo shutdown -h +10
>Restart
$sudo shutdown -r now
$sudo shutdown -r now
>Check file system while restart
$sudo shutdown -Fr now
List Device hardware info
===================
>sudo lshw -short
>sudo lshw -short -class disk(Filter disk only)
$sudo shutdown -Fr now
List Device hardware info
===================
>sudo lshw -short
>sudo lshw -short -class disk(Filter disk only)
>Sudo lvmdiskscan
Comments
Post a Comment