Basic Command for Linux and Ubuntu - Cloud Network

Networking | Support | Tricks | Troubleshoot | Tips

Buymecoffe

Buy Me A Coffee

Monday, October 14, 2019

Basic Command for Linux and Ubuntu

Image result for Basic Command for Linux and Ubuntu




Recognised Ubuntu flavours (APT)
Edubuntu — Ubuntu for education
Ubuntu GNOME — Ubuntu with the GNOME desktop environment
Kubuntu — Ubuntu with the K Desktop environment
Ubuntu Kylin — Ubuntu localised for China
Lubuntu — Ubuntu that uses LXDE
Mythbuntu — Designed for creating a home theatre PC with MythTV
Ubuntu Studio — Designed for multimedia editing and creation
Xubuntu — Ubuntu with the XFCE desktop environment

Links to Download Open Source
Ubuntu   ---- https://www.ubuntu.com/
Debian  ----- https://www.debian.org
Linux Mint  --- https://www.linuxmint.com
Puppy Linux -- https://www.puppylinux.org
TinyCore ---- http://distro.ibiblio.org/
MEPIS Linux --- http://www.mepis.org/
Zorin OS --- http://zorin-os.com/
FreeBSD--- http://www.freebsd.org

Recognised Linux flavours (YUM)
Redhat Linux --- http://in.redhat.com
CentOS --- http://www.centos.org/
OpenSUSE--- http://www.opensuse.org/
Fedora ---http://fedoraproject.org/
Slackware--- http://www.slackware.com/
OpenSolaris --- http://distrowatch.com/
IPFIRE     --- http://www.ipfire.org/



Sudo Means
sudo     (super user do)
su         (superuser)

To See Ip address and Mac address
ifconfig
ifconfig -a
ifconfig eth1 up
sudo lshw -C network
sudo ifconfig eth1 up
sudo /etc/init.d/networking restart

System Architecture
Distribution and version of Linux
uname -m
cat /proc/version

Kernel Requirements
uname -r

Memory Requirements
grep MemTotal /proc/meminfo
uname -m
grep SwapTotal /proc/meminfo

Automatic Memory Management
df -h /dev/shm/

Disk Space Requirements
df -h
df -h /tmp
df -h /home

mtr Command means - ping and traceroute                  
Type :- mtr google.com
swapon -s   check swap size

Install :- sudo apt-get install mtr 


Password
sudo smbpasswd -a <user_name>

1. Ctrl+x+e Command - open editor by typing vi, vim, nano, etc
2. nl Command  -  number the lines of a file
eg:- cat > file.txt
        nl file.txt

3. shuf Command - randomly select lines/files/folder from a file/folder
eg:-  ls
ls | shuf (shuffle Input)
ls | shuf -n1

4. To determine the size of the configured swap space, enter the following command:
# grep SwapTotal /proc/meminfo

ss Command  --  socket statistics similar to netstat command
last Command -- history of last logged in users
curl ifconfig.me  --  External IP address
tree command --
pstree --
<space> Command  -  (ls, pwd, uname, echo “hi” and who)
history
stat Command --  status information


mount | column -t  --  mounted filesystem
Ctr+l command -- clear
file
look Command - ubuntu
id -- user and group ids.
strace Command  -- troubleshooting
strace pwd
disown -a && exit Command  --- control jobs running in the terminal background
 lsb_release  ---  print distribution-specific information
lsb_release -a


getconf LONG_BIT Command -- machine architecture
watch -t -n1 "date +%T|figlet  --  first install figlet
host and dig Commands  -  DNS lookup utility
dstat Command --  generates statistics relating to system resource
bind -p Command
nc -zv localhost 80
curl ipinfo.io -- ‘Geographical Location
find .  -user root   --- files with respect of the user (root) owned files
eg :- find . -user avi
apt-get build-dep ffmpeg -- dependency, automatically during the corresponding package installation





lsof -iTCP:80 -sTCP:LISTEN ---- process/service
ind -size +100M
Startx — :1

To determine the amount of free disk space on the system, enter the following command:
# df -k

To determine whether the required packages are installed, enter commands similar to the following:
# rpm -q package_name

To determine whether the required kernel is installed, enter the following command:
# uname -r

Internet troubleshoot
sysctl -p
sysctl -a | grep syn
sysctl -a | fgrep tcp
sysctl -A | grep na
sysctl -a | grep flush
ip route flush cache
ls -l /proc/sys/net/ipv4/route/flush

Open SSH Requirement for Minimal Installation
# rpm -qa | grep ssh

physical RAM size
grep MemTotal /proc/meminfo
free

the size of the configured swap space
grep SwapTotal /proc/meminfo

amount of space available in the /tmp directory,
df -h /tmp

 free disk space on the system
df -h

system architecture can run the software
uname -m

the processor architecture matches the Oracle software release to install
x86_64

1. LS (List Directory Contents)
ls (list files and directories)
ls -l (long listing)
ls -a (hidden)
Example :- drwxr-xr-x 2 ubuntu ubuntu 4096 June 5 14:50 Desktop
d (Directory)
rwxr-xr-x (owner, group and world)
1st ubuntu file is owned by user ubuntu
2nd ubuntu file belongs to user group ubuntu
4096 (file size in Bytes)
June 5 14:50 (date and time of last modification)
And at the end is the name of the File/Folder
ls -lh (Human Readable Format)
ls -F (will add the ‘/’ Character at the end each directory)





ls -r (List Files in Reverse Order)
eg :- Videos     Public    Music

ls -R (Recursively list Sub-Directories)
eg :- -rw-------. 1 root     root      33408 Aug  8 17:25 anaconda.log

ls -ltr (Reverse Output Order)
eg:- -rw-------. 1 root root  1586 Jul 31 02:17 anaconda-ks.cfg
        -rw-r--r--. 1 root root   683 Aug 19 09:59 0001.pcap

ls -lS (Sort Files by File Size)
eg:-  -rw-r--r--. 1 root root 48867 Jul 31 02:17 install.log
         drwxr-xr-x. 4 root root  4096 Aug 16 02:55 Downloads

ls -i (Display Inode number)
eg:- 20112 0001.pcap        23610 Documents

ls --version (Shows version)
ls --help (Help Page)
ls -l /tmp (List Directory Information)
ls -ld /tmp/ (/tmp directory)
ls -n (Display UID and GID of Files)
alias ls="ls -l" (ls command and it’s Aliases)
alias
unalias ls

2. lsblk (List Block Devices)
“lsblk -l (list Structure) 


3. md5sum (Compute and Check MD5 Message Digest)
eg :-  md5sum teamviewer_linux.deb

4. dd (Convert and Copy a file)
eg :- dd if=/home/user/Downloads/debian.iso of=/dev/sdb1 bs=512M; sync

5. uname
eg :- uname -a

Linux tecmint 3.8.0-19-generic #30-Ubuntu SMP Wed May 1 16:36:13 UTC 2013 i686 i686 i686 GNU/Linux
“Linux“: The machine’s kernel name.
“tecmint“: The machine’s node name.
“3.8.0-19-generic“: The kernel release.
“#30-Ubuntu SMP“: The kernel version.
“i686“: The architecture of the processor.
“GNU/Linux“: The operating system name.

5. uname
eg :- uname -a

Linux tecmint 3.8.0-19-generic #30-Ubuntu SMP Wed May 1 16:36:13 UTC 2013 i686 i686 i686 GNU/Linux
“Linux“: The machine’s kernel name.
“tecmint“: The machine’s node name.
“3.8.0-19-generic“: The kernel release.
“#30-Ubuntu SMP“: The kernel version.
“i686“: The architecture of the processor.
“GNU/Linux“: The operating system name.

6. history
7. mkdir (make directory)
8. touch (Update the access and modification times of each FILE to the current time)
eg :- touch newfilename

Permission
9. chmod (change file mode bits)

There exist 3 types of permission
Read (r)=4
Write(w)=2
Execute(x)=1
To change its permission and provide
read  - owner
write - group
and execute - world.

Now permission need to be set for 3 kinds of user and usergroup. The first is owner, then usergroup and finally world.
usergroup  ----  r-x (read and execute no write permission).
world is             –x (only execute).


Eg :- chmod 777 abc.sh

10. chown - (change file owner and group)
ls -l
11. apt  -  (Advanced Package Tool)
12. tar - (Tape Archive )
tar -zxvf abc.tar.gz (Remember 'z' for .tar.gz)
tar -jxvf abc.tar.bz2 (Remember 'j' for .tar.bz2)
tar.gz‘ means gzipped ---  ‘tar.bz2

13. cal - Calendar
cal 02 1835
14. date
15. cat
16.  Wildcard            Matches
   *            zero or more characters
   ?            exactly one character
[abcde]            exactly one character listed
 [a-e]            exactly one character in the given range
[!abcde]        any character that is not listed
 [!a-e]            any character that is not in the given range
{debian,linux}        exactly one entire word in the options given

17. cp - Copy
18. mv - moves
19. pwd - (print working directory
20. cd - change directory


How to Enable EPEL Repository for RHEL/

What is EPEL
EPEL (Extra Packages for Enterprise Linux) is open source and free community based repository project from Fedora team which provides 100% high quality add-on software packages for Linux distribution including RHEL (Red Hat Enterprise Linux), CentOS, and Scientific Linux. Epel project is not a part of RHEL/Cent OS but it is designed for major Linux distributions by providing lots of open source packages like networking, sys admin, programming, monitoring and so on. Most of the epel packages are maintained by Fedora repo.

Why we use EPEL repository?
provides lots of open source packages to install via Yum.
Epel repo is 100% open source and free to use.
It does not provide any core duplicate packages and no compatibility issues.
All epel packages are maintained by Fedora repo.

RHEL/CentOS 6  32-Bit
1. wget http://download.fedoraproject.org/pub/epel/6/i386/epel-release-6-8.noarch.rpm
2. rpm -ivh epel-release-6-8.noarch.rpm
          
RHEL/CentOS 6  64-Bit
wget http://download.fedoraproject.org/pub/epel/6/x86_64/epel-release-6-8.noarch.rpm
# rpm -ivh epel-release-6-8.noarch.rpm



How Do I Verify EPEL Repo?
yum repolist

How Do I Use EPEL Repo?
yum --enablerepo=epel info zabbix
zabbix is a example

install zabbix
yum --enablerepo=epel install zabbix

Note: The epel configuration file is located under /etc/yum.repos.d/epel.repo.
This way you can install as many as high standard open source packages using EPEL repo.