Best Linux Guide And Command Explanation 11-20-2013, 12:26 AM
#1
S u p H C
![[Image: SC4TIGb.png]](http://i.imgur.com/SC4TIGb.png)
List all files and folders <folderName> list files in folder
Detailed list, Human readable
List jpeg files only
Result for file only
Change directory if folder name has spaces use β β
Go to root
Go up one folder, tip: ../../../
Disk usage of folders, human readable
Only show disc usage of folders
Print working directory
Shows manual (RTFM)
![[Image: nXxxvKt.png]](http://i.imgur.com/nXxxvKt.png)
From the top
Sshow content of file
From the bottom -n <oflines> <fileName>
Create new folder
Copy image to folder
Copy and rename a folder
Copy all of *<file type> to folder
Move file to a folder
Move folder in folder
Rename file
Move folder up in hierarchy
Delete file (s)
Ask for confirmation each file
Force deletion of a file
Delete folder
Physical link
Symbolic link
![[Image: 5SJoH6Z.png]](http://i.imgur.com/5SJoH6Z.png)
List manual pages for subject
Display man pages containing keyword
Show the manual for command
Make a pdf of a manual page
Show full path name of command
See how long a command takes
Show possible locations of app
Show which app will be run by default; it shows the full path
![[Image: 86wwtPY.png]](http://i.imgur.com/86wwtPY.png)
Search for pattern in files
Search recursively for pattern in dir
Search for pattern in the output of command
Find all instances of file
Starting with the root directory, look for the file called filename
Starting with the root directory, look for the file containing the string filename
Find a file called filename using the locate command; this assumes you
have already used the command updatedb (see next)
Create or update the database of files on all file systems attached to the Linux root directory
Show the subdirectory containing the executable file called filename
Starting with the directory called dir, look for and list all files containing TextStringToFind
![[Image: cF1wRfc.png]](http://i.imgur.com/cF1wRfc.png)
Change the permissions of file to octal, which can be found separately for user, group, and world by adding: 4 β read ®, 2 β write (w), 1 β execute (x)
Examples:
chmod 777 β read, write, execute for all
chmod 755 β rwx for owner, rx for group and world
For more options, see man chmod.
![[Image: n08V9QD.png]](http://i.imgur.com/n08V9QD.png)
Connect to host as user
Connect to host on port port as user
Add your key to host for user to enable a keyed or passwordless login
![[Image: 7OxUKBL.png]](http://i.imgur.com/7OxUKBL.png)
List IP addresses for all devices on the local machine
Ping host and output results
Get whois information for domain
Get DNS information for domain
Reverse lookup host
Download file
Continue a stopped download
Give accountname a new password
Log in as superuser from current login
Stop being superuser and revert to normal user
![[Image: nJH0uAV.png]](http://i.imgur.com/nJH0uAV.png)
Display your currently active processes
Display all running processes
Kill process id pid
Kill all processes named proc (use with extreme caution)
Lists stopped or background jobs; resume a stopped job in the background
Brings the most recent job to foreground
Brings job n to the foreground
![[Image: 19APdU5.png]](http://i.imgur.com/19APdU5.png)
Installation from source
install a DEB package (Debian / Ubuntu / Linux Mint)
install a RPM package (Red Hat / Fedora)
(YUM) Yellowdog Updater Modified
Install the specified packages
Remove / Uninstall the specified packages
Remove package called httpd, enter:
Display the list of available packages
Display list of group software
Display list of updated software
List all installed packages
Find out if httpd package installed or not:
Check for and update specified package
To check for and update httpd package
Finding packages containing missing dependencies when installing software from source
Pacman
Lists all installed packages
Install packages (from file)
Updates the list of packages and installs a given
package (from repository)
Update packages installed on your system with
the latest versions in the archives
Updates the list of packages and upgrade
the packages installed on the system
Remove a package
Remove a package, delete the configuration
files and eliminates the dependencies
Delete orphaned packages
Try searching within the package database
Show the detailed information on a given package
Clear the system cache of video packets
![[Image: 9nHYbDQ.png]](http://i.imgur.com/9nHYbDQ.png)
Shutdown the system now and do not reboot
Stop all processes - same as above
Shutdown the system in 5 minutes and reboot
Shutdown the system now and reboot
Stop all processes and then reboot - same as above
Start the X system
I hope I learned something new to you. :>
Share it but don't forget to give credits.
- dR.0xYw0Rm aka Gaara
Today I am going to explain you what is Linux and alot of useful Linux terminal commands.
If you still haven't decide which Linux distro to choose I would highly recommend you checking my guide:
* How To Choose The Right Linux Distribution For You *
![[Image: GqXfDlL.png]](http://i.imgur.com/GqXfDlL.png)
Linux is a Unix-like and POSIX-compliant computer operating system assembled under the model of free and open source software development and distribution. It is a freeware and generally speaking its free from Virus and other malware infections. The main form of distribution are Linux distributions. It's a bit harder to learn at first , a lot of command line stuff but when you get to grips with it it can be very rewarding.
The big thing about linux is that it is open source, which means there are virtually no license limitations so people can do what they want with it, this can be very useful for people who have very specific requirements and dont want to get involved in messy licensing as you would with windows for example.
![[Image: vr4OpUJ.png]](http://i.imgur.com/vr4OpUJ.png)
Linux is multi platform.
This means that by choosing Linux, you choose a portable operating system on which you can run or develop portable applications. Linux runs on Sparc(Sun), Alpha(Compaq), Mips, ARM, x86(Intel), PowerPC, 680x0(Motorola), RS6000 (IBM), and so on... So,when choosing Linux for your operating system,you open choices to you. You don't reduce your choices to noΒ otherc hoiceΒ than Intel running IBM compatible.
Linux is not under the control of NSA.
The NSA (NationalSecurityAgency,USA) and Microsoft recognized that two sets of secret keys where shipped with Windows in order to allow either Microsoft and NSA to enter any Windows running computer in the world Linux is openΒ source. Anybody can check if there is such a backΒdoor in it. NSA is working on a certificated secure version of the Linux kernel for USA use,because they know Windows is not secure.
![[Image: yM7eivE.png]](http://i.imgur.com/yM7eivE.png)
Note: The commands below are top 5 in my opinion not officially.
"sudo"
Sudo best thought of as βSuperuser Doβ, allows you to run commands with root/administrator permissions.
For example: You can't do:
If you are not logged in as "root"
So all we have to do is to add "sudo" at the beginning of the command.
"apt-get install"
Allows you to install applications available in the Ubuntu Software Center and added PPAs can be installed from the command line using βapt-get installβ.
I.E: (Installing tor on your machine)
"top"
Top command which is one of the most frequently used commands in our daily system administrative jobs. Top command displays processor activity of your Linux box and also displays tasks managed by kernel in real-time. Itβll show processor and memory are being used and other information like running processes. This may help you to take correct action. top command found in UNIX-like operating systems. You can perform different actions with that , even killing processes.
"cd"βcdβ (Change Directory) is the command used for navigating folders in the Terminal.
βcd folder/name/β will navigate you into that folder
To go back on folder type
Typing βcdβ on its own returns you to the βHomeβ folder
Tip: Remember you can always use the βTabβ button to auto-complete commands and locations in the Terminal.
"ls"
ls command is one of the most frequently used command in Linux. I believe ls command is the first command you may use when you get into the command prompt of Linux Box. We use ls command daily basis and frequently even though we may not aware and never use all the option available. In this article, weβll be discussing basic ls command where we have tried to cover as much parameters as possible.
![[Image: LOHIUyr.png]](http://i.imgur.com/LOHIUyr.png)
Show the current date and time
Show this month's calendar
Show current uptime
Display who is online
Who you are logged in as
Display information about user
Show kernel information
Cpu information
Memory information
Show disk usage
Show directory space usage
Show memory and swap usage
![[Image: 45T540u.png]](http://i.imgur.com/45T540u.png)
Clear the terminal
Show content of file
Logout
Go up/down the terminal
From the top
Cursor to start of line
Cursor the end of line
Delete left of the cursor
From the bottom
Delete right of the cursor
Delete word on the left
Paste (after CTRL U,K or W)
Create new folder
Auto completion of file or command
Reverse search history
Repeat last command
If you still haven't decide which Linux distro to choose I would highly recommend you checking my guide:
* How To Choose The Right Linux Distribution For You *
![[Image: GqXfDlL.png]](http://i.imgur.com/GqXfDlL.png)
Linux is a Unix-like and POSIX-compliant computer operating system assembled under the model of free and open source software development and distribution. It is a freeware and generally speaking its free from Virus and other malware infections. The main form of distribution are Linux distributions. It's a bit harder to learn at first , a lot of command line stuff but when you get to grips with it it can be very rewarding.
The big thing about linux is that it is open source, which means there are virtually no license limitations so people can do what they want with it, this can be very useful for people who have very specific requirements and dont want to get involved in messy licensing as you would with windows for example.
![[Image: vr4OpUJ.png]](http://i.imgur.com/vr4OpUJ.png)
Linux is multi platform.
This means that by choosing Linux, you choose a portable operating system on which you can run or develop portable applications. Linux runs on Sparc(Sun), Alpha(Compaq), Mips, ARM, x86(Intel), PowerPC, 680x0(Motorola), RS6000 (IBM), and so on... So,when choosing Linux for your operating system,you open choices to you. You don't reduce your choices to noΒ otherc hoiceΒ than Intel running IBM compatible.
Linux is not under the control of NSA.
The NSA (NationalSecurityAgency,USA) and Microsoft recognized that two sets of secret keys where shipped with Windows in order to allow either Microsoft and NSA to enter any Windows running computer in the world Linux is openΒ source. Anybody can check if there is such a backΒdoor in it. NSA is working on a certificated secure version of the Linux kernel for USA use,because they know Windows is not secure.
![[Image: yM7eivE.png]](http://i.imgur.com/yM7eivE.png)
Note: The commands below are top 5 in my opinion not officially.
"sudo"
Code:
sudoSudo best thought of as βSuperuser Doβ, allows you to run commands with root/administrator permissions.
For example: You can't do:
Code:
apt-get updateIf you are not logged in as "root"
So all we have to do is to add "sudo" at the beginning of the command.
Code:
sudo apt-get update"apt-get install"
Code:
apt-get installAllows you to install applications available in the Ubuntu Software Center and added PPAs can be installed from the command line using βapt-get installβ.
I.E: (Installing tor on your machine)
Code:
apt-get install tor"top"
Code:
topTop command which is one of the most frequently used commands in our daily system administrative jobs. Top command displays processor activity of your Linux box and also displays tasks managed by kernel in real-time. Itβll show processor and memory are being used and other information like running processes. This may help you to take correct action. top command found in UNIX-like operating systems. You can perform different actions with that , even killing processes.
"cd"
Code:
cdβcd folder/name/β will navigate you into that folder
To go back on folder type
Code:
cd -Tip: Remember you can always use the βTabβ button to auto-complete commands and locations in the Terminal.
"ls"
Code:
ls![[Image: LOHIUyr.png]](http://i.imgur.com/LOHIUyr.png)
Show the current date and time
Code:
dateShow this month's calendar
Code:
calShow current uptime
Code:
uptimeDisplay who is online
Code:
wWho you are logged in as
Code:
whoamiDisplay information about user
Code:
finger userShow kernel information
Code:
uname -aCpu information
Code:
cat /proc/cpuinfoMemory information
Code:
cat /proc/meminfoShow disk usage
Code:
dfShow directory space usage
Code:
duShow memory and swap usage
Code:
free![[Image: 45T540u.png]](http://i.imgur.com/45T540u.png)
Clear the terminal
Code:
CTRL LShow content of file
Code:
cat <fileName>Logout
Code:
CTRL DGo up/down the terminal
Code:
SHIFT Page Up/DownFrom the top
Code:
headCursor to start of line
Code:
CTRL ACursor the end of line
Code:
CTRL EDelete left of the cursor
Code:
CTRL UFrom the bottom
Code:
tailDelete right of the cursor
Code:
CTRL KDelete word on the left
Code:
CTRL WPaste (after CTRL U,K or W)
Code:
CTRL YCreate new folder
Code:
mkdirAuto completion of file or command
Code:
TABReverse search history
Code:
CTRL RRepeat last command
Code:
!!![[Image: SC4TIGb.png]](http://i.imgur.com/SC4TIGb.png)
List all files and folders <folderName> list files in folder
Code:
ls -aDetailed list, Human readable
Code:
ls -lhList jpeg files only
Code:
ls -l *.jpgResult for file only
Code:
ls -lh <fileName>Change directory if folder name has spaces use β β
Code:
cd <folderName>Go to root
Code:
cd /Go up one folder, tip: ../../../
Code:
cd ..Disk usage of folders, human readable
Code:
du -hOnly show disc usage of folders
Code:
du -shPrint working directory
Code:
pwdShows manual (RTFM)
Code:
man <command>![[Image: nXxxvKt.png]](http://i.imgur.com/nXxxvKt.png)
From the top
Code:
headSshow content of file
Code:
cat <fileName>From the bottom -n <oflines> <fileName>
Code:
tailCreate new folder
Code:
mkdirCopy image to folder
Code:
cp image.jpg <folderName>/Copy and rename a folder
Code:
cp -R stuff otherStuffCopy all of *<file type> to folder
Code:
cp *.txt stuff/Move file to a folder
Code:
mv file.txt Documents/Move folder in folder
Code:
mv <folderName> <folderName2>Rename file
Code:
mv filename.txt filename2.txtMove folder up in hierarchy
Code:
mv <folderName>/ ..Delete file (s)
Code:
rm <fileName> ..Ask for confirmation each file
Code:
rm -i <fileName> ..Force deletion of a file
Code:
rm -f <fileName>Delete folder
Code:
rm -r <foldername>/Physical link
Code:
ln file1 file2Symbolic link
Code:
ln -s file1 file2![[Image: 5SJoH6Z.png]](http://i.imgur.com/5SJoH6Z.png)
List manual pages for subject
Code:
apropos subjectDisplay man pages containing keyword
Code:
man -k keywordShow the manual for command
Code:
man commandMake a pdf of a manual page
Code:
man -t man | ps2pdf - > man.pdfShow full path name of command
Code:
which commandSee how long a command takes
Code:
time commandShow possible locations of app
Code:
whereis appShow which app will be run by default; it shows the full path
Code:
which app![[Image: 86wwtPY.png]](http://i.imgur.com/86wwtPY.png)
Search for pattern in files
Code:
grep pattern filesSearch recursively for pattern in dir
Code:
grep -r pattern dirSearch for pattern in the output of command
Code:
command | grep patternFind all instances of file
Code:
locate fileStarting with the root directory, look for the file called filename
Code:
find / -name filenameStarting with the root directory, look for the file containing the string filename
Code:
find / -name β*filename*β βFind a file called filename using the locate command; this assumes you
have already used the command updatedb (see next)
Code:
locate filenameCreate or update the database of files on all file systems attached to the Linux root directory
Code:
updatedbShow the subdirectory containing the executable file called filename
Code:
which filenameStarting with the directory called dir, look for and list all files containing TextStringToFind
Code:
grep TextStringToFind /dir β![[Image: cF1wRfc.png]](http://i.imgur.com/cF1wRfc.png)
Change the permissions of file to octal, which can be found separately for user, group, and world by adding: 4 β read ®, 2 β write (w), 1 β execute (x)
Examples:
chmod 777 β read, write, execute for all
chmod 755 β rwx for owner, rx for group and world
For more options, see man chmod.
Code:
chmod octal file![[Image: n08V9QD.png]](http://i.imgur.com/n08V9QD.png)
Connect to host as user
Code:
ssh user@hostConnect to host on port port as user
Code:
ssh -p port user@hostAdd your key to host for user to enable a keyed or passwordless login
Code:
ssh-copy-id user@host![[Image: 7OxUKBL.png]](http://i.imgur.com/7OxUKBL.png)
List IP addresses for all devices on the local machine
Code:
ifconfigPing host and output results
Code:
ping hostGet whois information for domain
Code:
whois domainGet DNS information for domain
Code:
dig domainReverse lookup host
Code:
dig -x hostDownload file
Code:
wget fileContinue a stopped download
Code:
wget -c file[/code+
[IMG]http://i.imgur.com/Ll6RIhq.png[/IMG]
Create a new user call accountname
[code]adduser accountnameGive accountname a new password
Code:
passwd accountnameLog in as superuser from current login
Code:
suStop being superuser and revert to normal user
Code:
exit![[Image: nJH0uAV.png]](http://i.imgur.com/nJH0uAV.png)
Display your currently active processes
Code:
psDisplay all running processes
Code:
topKill process id pid
Code:
kill pidKill all processes named proc (use with extreme caution)
Code:
killall procLists stopped or background jobs; resume a stopped job in the background
Code:
bgBrings the most recent job to foreground
Code:
fgBrings job n to the foreground
Code:
fg n![[Image: 19APdU5.png]](http://i.imgur.com/19APdU5.png)
Installation from source
Code:
./configure
make
make installinstall a DEB package (Debian / Ubuntu / Linux Mint)
Code:
dpkg -i pkg.debinstall a RPM package (Red Hat / Fedora)
Code:
rpm -Uvh pkg.rpm(YUM) Yellowdog Updater Modified
Install the specified packages
Code:
yum install {package-name-1} {package-name-2}
Install package called httpd:
yum install httpdRemove / Uninstall the specified packages
Remove package called httpd, enter:
Code:
yum remove {package-name-1} {package-name-2}
yum remove httpdDisplay the list of available packages
Code:
yum list allDisplay list of group software
Code:
yum grouplistDisplay list of updated software
Code:
yum list updatesList all installed packages
Code:
rpm -qa
yum list installedFind out if httpd package installed or not:
Code:
rpm -qa | grep httpd*
yum list installed httpdCheck for and update specified package
Code:
yum update {package-name}To check for and update httpd package
Code:
yum update httpdFinding packages containing missing dependencies when installing software from source
Code:
yum whatprovides */<dependencyName>Pacman
Lists all installed packages
Code:
pacman -QInstall packages (from file)
Code:
pacman -UUpdates the list of packages and installs a given
package (from repository)
Code:
pacman -SyUpdate packages installed on your system with
the latest versions in the archives
Code:
pacman -SuUpdates the list of packages and upgrade
the packages installed on the system
Code:
pacman -SyuRemove a package
Code:
pacman -RcRemove a package, delete the configuration
files and eliminates the dependencies
Code:
pacman -RsnDelete orphaned packages
Code:
pacman -Rs $(pacman -Qqtd)Try searching within the package database
Code:
pacman -SsShow the detailed information on a given package
Code:
pacman -SiClear the system cache of video packets
Code:
pacman -Sc![[Image: 9nHYbDQ.png]](http://i.imgur.com/9nHYbDQ.png)
Shutdown the system now and do not reboot
Code:
shutdown -h nowStop all processes - same as above
Code:
haltShutdown the system in 5 minutes and reboot
Code:
shutdown -r 5Shutdown the system now and reboot
Code:
shutdown -r nowStop all processes and then reboot - same as above
Code:
rebootStart the X system
Code:
startxI hope I learned something new to you. :>
Share it but don't forget to give credits.
- dR.0xYw0Rm aka Gaara
If you need help , drop me a PM and I will help you with the best I can !
![[Image: V7mYdF6.png]](http://i.imgur.com/V7mYdF6.png)
![[+]](https://sinister.ly/images/modern/collapse_collapsed.png)
![[Image: OilyCostlyEwe.gif]](http://fat.gfycat.com/OilyCostlyEwe.gif)