لینوکس و شبکه



یک تجربه: در دبیان ۹ برای اینکه firmware کارت شبکه یو اس بی رو بشناسانیم از روش زیر استفاده میکنیم



add to /etc/apt/source.list
deb http://ftp.fr.debian.org/debian jessie main contrib non-free
deb http://httpredir.debian.org/debian/ stretch main contrib non-free

sudo apt-get install debian-reference
apt-get update && apt-get install firmware-iwlwifi
sudo apt-get update && apt-get install firmware-iwlwifi
sudo apt-get update && sudo apt-get install firmware-iwlwifi
sudo apt-get install modplug-tools 
sudo apt-get install modprobe
sudo apt-get install modprob
sudo apt-get install kmod
sudo apt-get install wicd
sudo  apt-get install firmware-realtek
sudo  apt-get install firmware-iwlwifi 
sudo  apt-get install firmware-linux
sudo  apt-get install amd64-microcode firmware-linux-nonfree firmware-misc-nonfree


توسط این برنامه می‌توان فایل یا متن از طریق شبکه منتقل نمود:

۱-ارسال متن:

در گیرنده دستور زیر زده شود:
nc -l -p PortNumber
در سمت فرستنده نیز دستور زیر زده شود:
echo "TEXT" | netcat  [Destination] PortNumber

2-ارسال فایل:

درسمت گیرنده دستور زیر زده شود
nc -l -p 1234 > out.file
در سمت فرستنده نیز دستور زیر زده شود
nc -w 3 [destination] 1234 < out.file


3-ارسال فایل-فشرده سازی

درسمت فرستنده دستور زیر زده شود
tar cfp - /some/dir | compress -c | nc -w 3 [destination] 1234
در سمت گیرنده نیز دستور زیر زده شود
nc -l -p 1234 | uncompress -c | tar xvfp -


4-ارسال فایل- محتویات یک هارد (پارتیشن)

درسمت فرستنده دستور زیر زده شود
dd if=/dev/hda3 | gzip -9 | nc -l 3333
در سمت گیرنده نیز دستور زیر زده شود
nc [destination] 3333 | pv -b > hdImage.img.gz



LINK


  select
case
when b.table_name is null then
'unindexed'
else
'indexed'
end as status,
a.table_name as table_name,
a.constraint_name as fk_name,
a.fk_columns as fk_columns,
b.index_name as index_name,
b.index_columns as index_columns
from
(
select 
a.table_name,
a.constraint_name,
listagg(a.column_name, ',') within
group (order by a.position) fk_columns
from
dba_cons_columns a,
dba_constraints b
where
a.constraint_name = b.constraint_name
and 
b.constraint_type = 'R'
and 
a.owner = '&&schema_owner'
and 
a.owner = b.owner
group by 
a.table_name, 
a.constraint_name
) a
,(
select 
table_name,
index_name,
listagg(c.column_name, ',') within
group (order by c.column_position) index_columns
from
dba_ind_columns c
where 
c.index_owner = '&&schema_owner'
group by
table_name, 
index_name
) b
where
a.table_name = b.table_name(+)
and 
b.index_columns(+) like a.fk_columns || '%'
order by 
1 desc, 2;


برای نمایش یک پیغام بصورت notification از دستور زیر استفاده میکنیم:
notify-send 'title' 'message'
notify-send -u critical "job complete"
zenity --timeout=180 --notification --text "salam behrooooooooooooooz"

برای نمایش یک پیغام بصورت messageBox که بصورت یک ویندوز ظاهر شود و متنی را به نمایش گذارد از دستور زیر استفاده می‌شود:

zenity --error --text="An error occurred\!" --title="Warning\!"
find /usr | zenity --progress --pulsate --auto-close --auto-kill --text="Working."
zenity --question --text="Do you wish to continue/?"
zenity \
--info \
--text="<span size=\"xx-large\">Time is $(date +%Hh%M).</span>\n\nGet your <b>coffee</b>." \
--title="Coffee time" \
--ok-label="Sip"
my_variable=$(zenity --entry --text="What's my variable:");echo $my_variable
zenity --calendar
اگر بخواهیم در یک متن با خاصیت بلی ویا خیر در قلب ترمینال نمایش شود (همانند ok و Cancell در حین نصب آپاچی) از دستور زیر استفاده می‌نماییم:
whiptail --title "Example Dialog" --msgbox "This is an example of a message box. You must hit OK to continue." 8 78

نمایش یک پنجره به سبک برنامه نویسی ویژوال:
echo My text | yad \
--text-info \
--width=400 \
--height=200

yad \
--title="Desktop entry editor" \
--text="Simple desktop entry editor" \
--form \
--field="Type:CB" \
--field="Name" \
--field="Generic name" \
--field="Comment" \
--field="Command:FL" \
--field="Icon" \
--field="In terminal:CHK" \
--field="Startup notify:CHK" "Application" "Name" "Generic name" "This is the comment" "/usr/bin/yad" "yad" FALSE TRUE \
--button="WebUpd8:2" \
--button="gtk-ok:0" \
--button="gtk-cancel:1"

دستوری برای گرفتن پسورد روت سیستم:
gksudo lsof
gksudo lsof | zenity --text-info --width 530


Create a Message Box:

whiptail --title "<message box title>" --msgbox "<text to show>" <height> <width>

Example:

#!/bin/bash
whiptail --title "Test Message Box" --msgbox "Create a message box with whiptail. Choose Ok to continue." 10 60





Create a Yes/No Box

whiptail --title "<dialog box title>" --yesno "<text to show>" <height> <width>

Example:

#!/bin/bash
if (whiptail --title "Test Yes/No Box" --yesno "Choose between Yes and No." 10 60) then
    echo "You chose Yes. Exit status was $?."
else
    echo "You chose No. Exit status was $?."
fi

Example:

#!/bin/bash
if (whiptail --title "Test Yes/No Box" --yes-button "Skittles" --no-button "M&M's"  --yesno "Which do you like better?" 10 60) then
    echo "You chose Skittles Exit status was $?."
else
    echo "You chose M&M's. Exit status was $?."
fi





Create a Free-form Input Box

whiptail --title "<input box title>" --inputbox "<text to show>" <height> <width> <default-text>

Example:

#!/bin/bash
PET=$(whiptail --title "Test Free-form Input Box" --inputbox "What is your pet's name?" 10 60 Wigglebutt 3>&1 1>&2 2>&3)
 
exitstatus=$?
if [ $exitstatus = 0 ]; then
    echo "Your pet name is:" $PET
else
    echo "You chose Cancel."
fi





Create a Password Box

whiptail --title "<password box title>" --passwordbox "<text to show>" <height> <width>

Example:

#!/bin/bash
PASSWORD=$(whiptail --title "Test Password Box" --passwordbox "Enter your password and choose Ok to continue." 10 60 3>&1 1>&2 2>&3)
 
exitstatus=$?
if [ $exitstatus = 0 ]; then
    echo "Your password is:" $PASSWORD
else
    echo "You chose Cancel."
fi





Create a Menu Box

whiptail --title "<menu title>" --menu "<text to show>" <height> <width> <menu height> [ <tag> <item> ] . . .

Example:

#!/bin/bash
OPTION=$(whiptail --title "Test Menu Dialog" --menu "Choose your option" 15 60 4 \
"1" "Grilled Spicy Sausage" \
"2" "Grilled Halloumi Cheese" \
"3" "Charcoaled Chicken Wings" \
"4" "Fried Aubergine"  3>&1 1>&2 2>&3)
 
exitstatus=$?
if [ $exitstatus = 0 ]; then
    echo "Your chosen option:" $OPTION
else
    echo "You chose Cancel."
fi





Create a Radiolist Dialog

whiptail --title "<radiolist title>" --radiolist "<text to show>" <height> <width> <list height> [ <tag> <item> <status> ] . . .

Example:

#!/bin/bash
DISTROS=$(whiptail --title "Test Checklist Dialog" --radiolist \
"What is the Linux distro of your choice?" 15 60 4 \
"debian" "Venerable Debian" ON \
"ubuntu" "Popular Ubuntu" OFF \
"centos" "Stable CentOS" OFF \
"mint" "Rising Star Mint" OFF 3>&1 1>&2 2>&3)
exitstatus=$?
if [ $exitstatus = 0 ]; then
    echo "The chosen distro is:" $DISTROS
else
    echo "You chose Cancel."
fi





Create a Checklist Dialog

whiptail --title "<checklist title>" --checklist "<text to show>" <height> <width> <list height> [ <tag> <item> <status> ] . . .

Example:

#!/bin/bash
DISTROS=$(whiptail --title "Test Checklist Dialog" --checklist \
"Choose preferred Linux distros" 15 60 4 \
"debian" "Venerable Debian" ON \
"ubuntu" "Popular Ubuntu" OFF \
"centos" "Stable CentOS" ON \
"mint" "Rising Star Mint" OFF 3>&1 1>&2 2>&3)
exitstatus=$?
if [ $exitstatus = 0 ]; then
    echo "Your favorite distros are:" $DISTROS
else
    echo "You chose Cancel."
fi





Create a Progress Bar

whiptail --gauge "<test to show>" <height> <width> <inital percent>

Example:

#!/bin/bash
{
    for ((i = 0 ; i <= 100 ; i+=20)); do
        sleep 1
        echo $i
    done
} | whiptail --gauge "Please wait while installing" 6 60 0




LINK1

Link2

Link3

Link4

Link5

Link6


روش زیر اتصا ل یک مسیر اف تی پی به یک فولدر در سروررا توضیح میدهد
ابتدا بسته curlftpfs  را نصب نمایید (نکته: اگر به مشکل خورد ابتدا بسته fuse را نصب نمایید)
vim /etc/init.d/mountftp
#!/bin/sh
#
# Run-level Startup script for curlftpfs
#
# chkconfig: 345 91 19
# description: Startup/Shutdown the curlftpfs
 
# FTP user, password, and host (you can specify the port also eg. ftp.example.com:2002)
ftpUser=user                    #نام کاربری از اف تی پی
ftpPass=password                #پسورد کاربر اف تی پی
ftpHost=ftp.example.com         #مسیر  اف تی پی مورد نظر که باید به  فولدر متصل شود
mPath="/var/mounted/ftp"      #فولدر مورد نظر در سرور فعلی که قرار است مسیر اف تی پی  به آن متصل شود
 
# Create the mounted to dir if doesn't exist
if [ ! -d $mPath ]; then
    mkdir -p $mPath
fi
 
case "$1" in
    start)
        curlftpfs $ftpHost $mPath -o user=$ftpUser:$ftpPass,allow_other
        ;;
    stop)
        fusermount -u $mPath      
        ;;
    reload|restart)
        $0 stop
        $0 start
        ;;
    *)
        echo "Usage: $0 start|stop|restart|reload"
        exit 1
esac
exit 0
سپس قرار دادن این اسکریپت در autostart به روش زیر:
chmod 755 /etc/init.d/mountftp
chkconfig mountftp on

 

دستورات قابل اجرا :
# Start
service mountftp start
 
# Restart and reload
service mountftp restart
service mountftp reload
 
# Stop
service mountftp stop


لینک مفید از این مطلب:  LINK


در لینوکس استفاده از پورت های کمتر از 1024 برای کاربران عادی مجاز نمیباشد، در چنین حالتی مثلا ما اگر بخواهیم سامانه خود را روی پورت 80 بالا بیاوریم که پورت پیش فرض وب میباشد، ناچاریم با استفاده از sudo این کار را بکنیم که ایرادات و مشکلات خاص خود را دارد.

authbind ابزاری میباشد که به ما اجازه میدهد پورت های خاصی را برای کاربران خاص باز کنیم.

در توضیح مرحله به مرحله زیر فرض ما این است که میخواهیم پورت 80 را برای کاربری به نام user باز کنیم:

1- ابتدا به پوشه /etc/default/ رفته و یک فایل به نام کاربر مورد نظر ایجاد میکنیم:
cd /etc/default
sudo vim user
2- در درون فایل user مقدار زیر را مینویسیم
AUTHBIND=yes

 3- ابزار authbind را نصب میکنیم:
sudo apt-get install authbind
4- دستورات زیر را اجرا میکنیم:
sudo touch /etc/authbind/byport/80
sudo chmod 755 /etc/authbind/byport/80
sudo chown user:user /etc/authbind/byport/80


1) ابتدا کلیدهای ترکیبی Win+R را فشار دهید و در محیط Run ، عبارت notepad را وارد نمایید تا نرم‌ افزار Notepad ویندوز باز شود.
✳️در محیط Notepad کد زیر را Copy و Paste نمایید:

taskkill f fi "status eq not responding"

✳️اکنون از منوی File بر روی Save as کلیک کنید.
سپس فایل را با نام دلخواه و پسوند bat. در صفحه دسکتاپ ویندوز ذخیره نمایید به عنوان مثال closeproccess.bat
2) حالا در صورتی که یک یا چند برنامه هنگ کرد، کافی است به صفحه دسکتاپ مراجعه کنید و بر روی این فایل جدید ایجاد شده دوبار کلیک کنید.
با اجرای این فایل، تمام پنجره‌های هنگ کرده برنامه‌ها بسته می‌شود.
این رو هم بگم که این ترفند بر روی کلیه نسخه‌های ویندوز کار میکنه.

نصب در کلاینت

در سمت کلایت باید سرویس NTP را نصب نمایید:
sudo apt-get install ntp
sudo yum install ntp

بعد از نصب در فایل مسیر زیر آدرس سرور را مشخص نمایید:
sudo vim /etc/ntp.conf
 
server 0.debian.pool.ntp.org iburst
server 1.debian.pool.ntp.org iburst
server 2.debian.pool.ntp.org iburst
server 3.debian.pool.ntp.org iburst
نکته: عبارت iburst را در مقابل سرور قرار بدهید تا این که شدت کوئری زدن به سرور افزایش یابد (حتی در صورتی که امکان sync شدن برقرا نیست بصورت force عمل sync صورت گیرد)

بعد از این که تنظیمات انجام  شد سرویس را ریست نمایید:
sudo /etc/init.d/ntpd restart
 

تست کارکرد سرویس

از دستور زیر برای مشاهده کارایی استفاده می‌کنیم:
$ ntpq -pn
     remote           refid      st t when poll reach   delay   offset  jitter
==============================================================================
*198.60.22.240   .GPS.            1 u  912 1024  377    0.488   -0.016   0.098
+199.104.120.73  .GPS.            1 u   88 1024  377    0.966    0.014   1.379
-155.98.64.225   .GPS.            1 u   74 1024  377    2.782    0.296   0.158
-137.190.2.4     .GPS.            1 u 1020 1024  377    5.248    0.194   0.371
-131.188.3.221   .DCFp.           1 u  952 1024  377  147.806   -3.160   0.198
-217.34.142.19   .LFa.            1 u  885 1024  377  161.499   -8.044   5.839
-184.22.153.11   .WWVB.           1 u  167 1024  377   65.175   -8.151   0.131
+216.218.192.202 .CDMA.           1 u   66 1024  377   39.293    0.003   0.121
-64.147.116.229  .ACTS.           1 u   62 1024  377   16.606    4.206   0.216

توضیحات  موارد بالا

    remote- The remote server you wish to synchronize your clock with
    refid- The upstream stratum to the remote server. For stratum 1 servers, this will be the stratum 0 source.
    st- The stratum level, 0 through 16.
    t- The type of connection. Can be "u" for unicast or manycast, "b" for broadcast or multicast, "l" for local reference clock, "s" for symmetric peer, "A" for a manycast server, "B" for a broadcast server, or "M" for a multicast server
    when- The last time when the server was queried for the time. Default is seconds, or "m" will be displayed for minutes, "h" for hours and "d" for days.
    poll- How often the server is queried for the time, with a minimum of 16 seconds to a maximum of 36 hours. It's also displayed as a value from a power of two. Typically, it's between 64 seconds and 1024 seconds.
    reach- This is an 8-bit left shift octal value that shows the success and failure rate of communicating with the remote server. Success means the bit is set, failure means the bit is not set. 377 is the highest value.
    delay- This value is displayed in milliseconds, and shows the round trip time (RTT) of your computer communicating with the remote server.
    offset- This value is displayed in milliseconds, using root mean squares, and shows how far off your clock is from the reported time the server gave you. It can be positive or negative.
    jitter- This number is an absolute value in milliseconds, showing the root mean squared deviation of your offsets.

 

علامت‌های کناری در remote server:

  • Next to the remote server, you'll notice a single character. This character is referred to as the "tally code", and indicates whether or not NTP is or will be using that remote server in order to synchronize your clock. Here are the possible values
  • " " Discarded as not valid. Could be that you cannot communicate with the remote machine (it's not online), this time source is a ".LOCL." refid time source, it's a high stratum server, or the remote server is using this computer as an NTP server.
    "x" Discarded by the intersection algorithm.
    "." Discarded by table overflow (not used).
    "-" Discarded by the cluster algorithm.
    "+" Included in the combine algorithm. This is a good candidate if the current server we are synchronizing with is discarded for any reason.
    "#" Good remote server to be used as an alternative backup. This is only shown if you have more than 10 remote servers.
    "*" The current system peer. The computer is using this remote server as its time source to synchronize the clock
    "o" Pulse per second (PPS) peer. This is generally used with GPS time sources, although any time source delivering a PPS will do. This tally code and the previous tally code "*" will not be displayed simultaneously.
 

توضیحات ستون refid:


     IP address- The IP address of the remote peer or server.
    .ACST.- NTP manycast server.
    .ACTS.- Automated Computer Time Service clock reference from the American National Institute of Standards and Technology.
    .AUTH.- Authentication error.
    .AUTO.- Autokey sequence error.
    .BCST.- NTP broadcast server.
    .CHU.- Shortwave radio receiver from station CHU operating out of Ottawa, Ontario, Canada.
    .CRYPT.- Autokey protocol error
    .DCFx.- LF radio receiver from station DCF77 operating out of Mainflingen, Germany.
    .DENY.- Access denied by server.
    .GAL.- European Galileo satellite receiver.
    .GOES.- American Geostationary Operational Environmental Satellite receiver.
    .GPS.- American Global Positioning System receiver.
    .HBG.- LF radio receiver from station HBG operating out of Prangins, Switzerland.
    .INIT.- Peer association initialized.
    .IRIG.- Inter Range Instrumentation Group time code.
    .JJY.- LF radio receiver from station JJY operating out of Mount Otakadoya, near Fukushima, and also on Mount Hagane, located on Kyushu Island, Japan.
    .LFx.- Generic LF radio receiver.
    .LOCL.- The local clock on the host.
    .LORC.- LF radio receiver from Long Range Navigation (LORAN-C) radio beacons.
    .MCST.- NTP multicast server.
    .MSF.- National clock reference from Anthorn Radio Station near Anthorn, Cumbria.
    .NIST.- American National Institute of Standards and Technology clock reference.
    .PPS.- Pulse per second clock discipline.
    .PTB.- Physikalisch-Technische Bundesanstalt clock reference operating out of Brunswick and Berlin, Germany.
    .RATE.- NTP polling rate exceeded.
    .STEP.- NTP step time change. The offset is less than 1000 millisecends but more than 125 milliseconds.
    .TDF.- LF radio receiver from station TéléDiffusion de France operating out of Allouis, France.
    .TIME.- NTP association timeout.
    .USNO.- United States Naval Observatory clock reference.
    .WWV.- HF radio receiver from station WWV operating out of Fort Collins, Colorado, United States.
    .WWVB.- LF radio receiver from station WWVB operating out of Fort Collins, Colorado, United States.
    .WWVH.- HF radio receiver from station WWVH operating out of Kekaha, on the island of Kauai in the state of Hawaii, United States.

دستوری برای چک شدن این که سرور در چه وضعیتی قرار دارد:
sudo yum install ntp

$ ntpq -c peer -c as -c rl
     remote           refid      st t when poll reach   delay   offset  jitter
==============================================================================
 .               10.200.108.62    2 u   20   64    1    0.537    1.660   0.000
 .               .INIT.          16 u    -   64    0    0.000    0.000   0.000


ind assid status  conf reach auth condition  last_event cnt
===========================================================
  1 15488  9024   yes   yes  none    reject   reachable  2
  2 15489  8011   yes    no  none    reject    mobilize  1
 
associd=0 status=c012 leap_alarm, sync_unspec, 1 event, freq_set,
version="ntpd 4.2.6p5@1.2349-o Fri Jul 22 17:30:51 UTC 2016 (1)",
processor="x86_64", system="Linux/3.16.0-4-amd64", leap=11, stratum=16,
precision=-23, rootdelay=0.000, rootdisp=0.300, refid=INIT,
reftime=00000000.00000000  Mon, Jan  1 1900  3:25:44.000,
clock=dd970af2.38da6724  Sun, Oct 22 2017 15:47:54.222, peer=0, tc=3,
mintc=3, offset=0.000, frequency=5.387, sys_jitter=0.000,
clk_jitter=0.000, clk_wander=0.000
در دستور بالا عبارت last_event اهمیت دارد که آبا سرور در دسترس قرار دارد یا خیر و این که در ستون reach عبارت yes هست یا no (yes یعنی از سرور مورد نظر در حال گرفتن دیتا است)
تست دیگری که در سمت کلاینت اطلاعات مفیدی به کاربر میدهد
$ ntpq
ntpq> as
ind assid status  conf reach auth condition  last_event cnt
===========================================================
  1 45592  9444   yes   yes  none candidate   reachable  4
  2 45593  962a   yes   yes  none  sys.peer    sys_peer  2
  3 45594  9414   yes   yes  none candidate   reachable  1

ntpq> exit
$
لینک های مفید:




sudo vim /etc/ntp.conf

# /etc/ntp.conf, configuration for ntpd; see ntp.conf(5) for help
driftfile /var/lib/ntp/ntp.drift
# Enable this if you want statistics to be logged.
#statsdir /var/log/ntpstats/
statistics loopstats peerstats clockstats
filegen loopstats file loopstats type day enable
filegen peerstats file peerstats type day enable
filegen clockstats file clockstats type day enable
# You do need to talk to an NTP server or two (or three).
#server ntp.your-provider.example
# pool.ntp.org maps to about 1000 low-stratum NTP servers.  Your server will
# pick a different set every time it starts up.  Please consider joining the
# pool: <http://www.pool.ntp.org/join.html>
server 0.debian.pool.ntp.org iburst
server 1.debian.pool.ntp.org iburst
server 2.debian.pool.ntp.org iburst
server 3.debian.pool.ntp.org iburst
# Access control configuration; see /usr/share/doc/ntp-doc/html/accopt.html for
# details.  The web page <http://support.ntp.org/bin/view/Support/AccessRestrictions>
# might also be helpful.
#
# Note that "restrict" applies to both servers and clients, so a configuration
# that might be intended to block requests from certain clients could also end
# up blocking replies from your own upstream servers.
# By default, exchange time with everybody, but don't allow configuration.
##restrict -4 default kod notrap nomodify nopeer noquery
##restrict -6 default kod notrap nomodify nopeer noquery
# Local users may interrogate the ntp server more closely.
restrict 127.0.0.1
restrict ::1
#restrict 192.168.0.0 mask 255.255.252.0
# Clients from this (example!) subnet have unlimited access, but only if
# cryptographically authenticated.
#restrict 192.168.123.0 mask 255.255.255.0 notrust
# If you want to provide time to your local subnet, change the next line.
# (Again, the address is an example only.)
#broadcast 192.168.123.255
# If you want to listen to time broadcasts on your local subnet, de-comment the
# next lines.  Please do this only if you trust everybody on the network!
#disable auth
#broadcastclient


کانفیگ‌های موحود همانند server که در فایل ntp.conf اعمال میشوند
server address [key key | autokey] [burst] [iburst] [version version] [prefer] [minpoll minpoll] [maxpoll maxpoll]
peer address [key key | autokey] [version version] [prefer] [minpoll minpoll] [maxpoll maxpoll]
broadcast address [key key | autokey] [version version] [minpoll minpoll] [ttl ttl]
manycastclient address [key key | autokey] [version version] [minpoll minpoll [maxpoll maxpoll] [ttl ttl]

server:
For type s and r addresses, this command mobilizes a persistent client mode association with the specified remote server or local radio clock. In this mode the local clock can synchronized to the remote server, but the remote server can never be synchronized to the local clock. This command should NOT be used for type b or m addresses.

peer:

For type s addresses (only), this command mobilizes a persistent symmetric-active mode association with the specified remote peer. In this mode the local clock can be synchronized to the remote peer or the remote peer can be synchronized to the local clock. This is useful in a network of servers where, depending on various failure scenarios, either the local or remote peer may be the better source of time. This command should NOT be used for type b, m or r addresses.

broadcast:
For type b and m addresses (only), this command mobilizes a persistent broadcast mode association. Multiple commands can be used to specify multiple local broadcast interfaces (subnets) and/or multiple multicast groups. Note that local broadcast messages go only to the interface associated with the subnet specified, but multicast messages go to all interfaces.In broadcast mode the local server sends periodic broadcast messages to a client population at the address specified, which is usually the broadcast address on (one of) the local network(s) or a multicast address assigned to NTP. The IANA has assigned the multicast group address 224.0.1.1 exclusively to NTP, but other nonconflicting addresses can be used to contain the messages within administrative boundaries. Ordinarily, this specification applies only to the local server operating as a sender; for operation as a broadcast client, see the broadcastclient or multicastclient commands below.
    
manycastclient:
For type m addresses (only), this command mobilizes a manycast client mode association for the multicast address specified. In this case a specific address must be supplied which matches the address used on the manycastserver command for the designated manycast servers. The NTP multicast address 224.0.1.1 assigned by the IANA should NOT be used, unless specific means are taken to avoid spraying large areas of the Internet with these messages and causing a possibly massive implosion of replies at the sender.The manycast command specifies that the local server is to operate in client mode with the remote servers that are discovered as the result of broadcast/multicast messages. The client broadcasts a request message to the group address associated with the specified address and specifically enabled servers respond to these messages. The client selects the servers providing the best time and continues as with the server command. The remaining servers are discarded as if never heard.

Options

autokey
All packets sent to and received from the server or peer are to include authentication fields encrypted using the autokey scheme described in the Authentication Options page.

burst
when the server is reachable and at each poll interval, send a burst of eight packets instead of the usual one packet. The spacing between the first and the second packets is about 16s to allow a modem call to complete, while the spacing between the remaining packets is about 2s. This is designed to improve timekeeping quality with the server command and s addresses.

iburst
When the server is unreachable and at each poll interval, send a burst of eight packets instead of the usual one. As long as the server is unreachable, the spacing between packets is about 16s to allow a modem call to complete. Once the server is reachable, the spacing between packets is about 2s. This is designed to speed the initial synchronization acquisition with the server command and s addresses and when ntpd is started with the -q option.

key key
All packets sent to and received from the server or peer are to include authentication fields encrypted using the specified key identifier with values from 1 to 65534, inclusive. The default is to include no encryption field.

minpoll minpoll
These options specify the minimum and maximum poll intervals for NTP messages, in seconds to the power of two. The maximum poll interval defaults to 10 (1,024 s), but can be increased by the maxpoll option to an upper limit of 17 (36.4 h). The minimum   poll interval defaults to 6 (64 s), but can be decreased by the minpoll option to a lower limit of 4 (16 s).

prefer
Marks the server as preferred. All other things being equal, this host will be chosen for synchronization among a set of correctly operating hosts. See the Mitigation Rules and the prefer Keyword page for further information.

ttl ttl
This option is used only with broadcast server and manycast client modes. It specifies the time-to-live ttl to use on broadcast server and multicast server and the maximum ttl for the expanding ring search with manycast client packets. Selection of the proper value, which defaults to 127, is something of a black art and should be coordinated with the network administrator.

version version
Specifies the version number to be used for outgoing NTP packets. Versions 1-4 are the choices, with version 4 the default.

 

اعمال محدودیت

تنظبمات موجود در سرور NTP را بصورت پیش فرض تغییر ندهید تا این که به هر سرور در هرکجا بتواند سرویس بدهد. اما اگر گاهی لازم شد تا به یک دامنه ای نخواهید سرویس بدهید از عبارت restricted برای محدود شدن آن آی پی استفاده نمایید.

# Hosts on local network are less restricted.
#restrict 192.168.1.0 mask 255.255.255.0 nomodify notrap

    ignore — All packets will be ignored, including ntpq and ntpdc queries.
    kod — a Kiss-o'-death” packet is to be sent to reduce unwanted queries.
    limited — do not respond to time service requests if the packet violates the rate limit default values or those specified by the discard command. ntpq and ntpdc queries are not affected. For more information on the discard command and the default values, see Section 22.16.2, Configure Rate Limiting Access to an NTP Service”.
    lowpriotrap — traps set by matching hosts to be low priority.
    nomodify — prevents any changes to the configuration.
    noquery — prevents ntpq and ntpdc queries, but not time queries, from being answered.
    nopeer — prevents a peer association being formed.
    noserve — deny all packets except ntpq and ntpdc queries.
    notrap — prevents ntpdc control message protocol traps.
    notrust — deny packets that are not cryptographically authenticated.
    ntpport — modify the match algorithm to only apply the restriction if the source port is the standard NTP UDP port 123.
    version — deny packets that do not match the current NTP version.



در سیستم عامل لینوکس شما قالبیت این را دارید که از محیط گرافیکی دلخواه خود استفاده نمایید: (

URL)

محیط کاربری اول:

MATE

در سه حالت زیر میتوانید نصب نمایید:

mate-desktop-environment-extras  (full + extras) : This will install the complete MATE desktop including a few extras.

mate-desktop-environment   (full) : This will install the complete MATE desktop environment.

mate-desktop-environment-core (core only) :  This is a minimalist MATE installation


If no graphical environment was present before, you will also need to install a display manager such as GDM or LightDM.

نکته: شاید لازم باشد بسته زیر را نیز نصب نمایید:

apt-get install xinit


محیط کاربری دوم:

Gnome

tasksl : Debian's selection of applications

gnome :  The full GNOME environment, including applications that are not officially part of the Upstream GNOME releases.

               It provides the recommended GNOME environment for Debian.

gnome-desktop-environment : The official upstream GNOME environment, minus a few packages.It is the closest to upstream recommendations.

gnome-core : Only the official core” modules of the GNOME desktop. Above packages depend on this one.





نکته: اگر فقط gnome core installation داشتید میتوانید برای نصب کامل‌تر از روش زیر نیز استفاده نمایید(نصب پوسته گنوم و بدون تمامی ابزارها)
apt-get install gnome-shell
apt-get install gnome-terminal
محیط کاربری سوم:

Xfce

محیط چهارم کاربری

LXDE

محیط کاربری پنجم(پلاسما):

KDE



نکته: برای  پایین آوردن محیط گرافیکی از دستورزیر  استفاده شود
در دبیان
/etc/init.d/gdm3 stop
در اوبونتو
/etc/init.d/lightdm stop





رفع مشکل bad gateway


گاهی اوقات ممکن است بدون دلیل مشخص صفحات، خطای bad gateway بدهد.

برای حل این مشکل می‌بایست به لاگ خطا در نشانی /var/log/nginx/error.log مراجعه کرد. اگر مشکل به صورت زیر باشد:

upstream sent too big header while reading response header from upstream,

می‌بایست در در تنظیمات کانفیگ (/etc/nginx/nginx.conf) سه خط زیر را نیز اضافه نمود:

proxy_buffer_size   128k;
proxy_buffers   4 256k;
proxy_busy_buffers_size   256k;


نکته: سرویس NginX همانند سرویس آپاچی در لینوکس و سرویس IIS در ویندوز است  که یک وب سرور به ما میدهد تا بتوانیم در بستر آن صفحات وب را به اشتراک بگذاریم


نصب: از دستورات package manager  سیستم عامل استفاده نمایید

Debian:  sudo apt-get install nginx
CentOS:  sudo yum install nginx

نکته: فایل های تنظیماتی سرویس  NginX  در مسیر etc/nginx قرار دارد

در فایل زیر:

/etc/nginx/nginx.conf

در خطی که با  عبارت  include آغاز میشود، مسیر زیر را مطابق نمونه قرار بدهید (در مسیر زیر برای هر دامنه یک فایل تنظیماتی بسازیم و کانفیگ هر سایت و یا دامنه را مجزا درون آن قرار دهید)

include /etc/nginx/site_available/*.conf;



یعنی در مسیر site_available به ازای هر فایلی که با پسوند conf وجود دارد و محتوی کانفیگ یک دامنه دلخواه است آن فایل خوانده می‌شود و یک دامنه را کانفیگ می‌کند.

بطور  مثال برای دامنه BMS  از فایل BMS.conf  در مسیر site-available  که در رهنگر مورد استفاده قرار میگرفته استفاده شد.


تمپلیت خوب برای استفاده در هر دامنه جدید:

upstream backend1  {
  ip_hash;
  server 172.16.85.237:8080 max_fails=3  fail_timeout=15s;
  server 172.16.85.238:8080 max_fails=3  fail_timeout=15s;
}
server {
        listen 80;
        server_name 172.16.85.244;
        client_max_body_size 250M;
 
location / {
        proxy_set_header X-Forwarded-Proto http;
        proxy_set_header Host $host;
        proxy_set_header X-Real-IP $remote_addr;
        proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
        proxy_set_header X-Forwarded-Proto $scheme;
        proxy_pass http://backend1;
        rewrite ^/$ /Ganjeh last;
       }
}



نکته:  کانفیگ بالا در فایل موجود در Site-available قرار خواهد گرفت.

بعنوان مثال برای فایل BMS.conf در رهنگر مشهد از شکل زیر استفاده شد:

#pstream backend  {
#  server 127.0.0.1:8080 ;
#}
server {
        listen 80;
        server_name 188.253.0.16;
        server_name mashhad.etrack.ir;
 
location / {
        proxy_set_header X-Forwarded-Proto http;
        proxy_set_header Host $host;
        proxy_set_header X-Real-IP $remote_addr;
        proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
        proxy_set_header X-Forwarded-Proto $scheme;
        proxy_pass http://127.0.0.1:8080/BMS;
       }
location /BMS {
        proxy_set_header X-Forwarded-Proto http;
        proxy_set_header Host $host;
        proxy_set_header X-Real-IP $remote_addr;
        proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
        proxy_set_header X-Forwarded-Proto $scheme;
        proxy_pass http://127.0.0.1:8080/BMS;
       }
 
location /MapCache {
        proxy_set_header X-Forwarded-Proto http;
        proxy_set_header Host $host;
        proxy_set_header X-Real-IP $remote_addr;
        proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
        proxy_set_header X-Forwarded-Proto $scheme;
        proxy_pass http://127.0.0.1:8080/MapCache;
       }
}



برای راه اندازی سرویس https در Nginx به روش زیر عمل کنید:

نکته: در هرباری که تغییری در تنظیمات انجام میدهید از دستور زیر استفاده نمایید تا مطمئن شوید که تغییرات درست بوده و موجب خطا نمیشود(سرویس را ریست ننمایید و از دستور زیر استفاده نمایید)

nginx -t

در زیر یک نمونه فایل config قبل ازآعمال تغییرات آورده شده تا تغییرات بوضوح مشاهده شود:

server {
         listen 80;
         server_name minitapp.ir;
         server_name www.minitapp.ir;
         client_max_body_size 300M;
         
         location / {
                proxy_pass http://192.168.2.101:8080/;
                proxy_set_header X-Forwarded-Proto https;
                proxy_set_header X-Real-IP $remote_addr;
                proxy_set_header Host $host;
                proxy_set_header X-Forwarded-For
                $proxy_add_x_forwarded_for;
        }
}

همچنین بلاک زیر بعد از بروز تغییرات می‌باشد:

server {
         listen 80;                                                         # http port
         server_name minitapp.ir;                                           # domain
         server_name www.minitapp.ir;
         client_max_body_size 300M;
         return 301 https://$server_name$request_uri;                       # Redirect to (return301 means redirect)
}
 
server {
         listen 443;                                                                                 # https port
         server_name minitapp.ir;                                                         # domain
         server_name www.minitapp.ir;                                                # domain
         client_max_body_size 300M;
         ssl on;
         ssl_certificate /etc/nginx/sites-cert/minitapp.ir.pem;            # Pem(CertificateFile) file
         ssl_certificate_key /etc/nginx/sites-cert/minitapp.ir.key;      # Key(CertificateFile) file
         ssl_session_timeout  5m;                                                        # Optional
         ssl_protocols  TLSv1;                                                               # Optional
         ssl_ciphers  HIGH:!aNULL:!MD5;                                             # Optional
         ssl_prefer_server_ciphers   on;                                               # Optional
 
         location / {
                proxy_pass http://192.168.2.101:8080/;
                proxy_set_header X-Forwarded-Proto https;
                proxy_set_header X-Real-IP $remote_addr;
                proxy_set_header Host $host;
                proxy_set_header X-Forwarded-For
                $proxy_add_x_forwarded_for;
        }
}

نکته: مسیر زیر یک مسیر دلخواه است که در سرور Nginx است که برای نگهداری فایل های ca در نظر گرفته شده است

/etc/nginx/sites-cert

نکته: return 301 به معنی این است که صفحات را به آدرس مورد نظر منتقل(redirect) کن

نکته: اگر بخواهیم فقط از سرویس https استفاده نماییم باید از داخل بلاک server با پورت 80 تمامی location ها را پاک کرده و به یک بلاک جدید با همان نام server و با شماره 443 (بجای 80) قرار دهیم (توجه شود که هیچ مقداری در location ها تغییر نخواهند کرد)-(توجه شود که directive با عنوان  proxy در تگ http مشاهده نشود)

نکته: اگر بخواهیم از هردو پروتکل http و https استفاده نماییم، آنگاه خط return 301 را از محل listen 80 حذف کرده و به بلاک های آن دست نمی‌زنیم.


  • 1. List Established Connections

    By default if we run the ss command with no further options specified it will display a list of open non-listening sockets that have established connections, so for example TCP, UDP or UNIX sockets.

    [root@centos7 ~]# ss | head -n 5
    Netid  State      Recv-Q Send-Q Local Address:Port      Peer Address:Port
    u_str  ESTAB      0      0       * 23740                * 23739
    u_str  ESTAB      0      0       * 23707                * 23706
    u_str  ESTAB      0      0       * 87021                * 88383
    u_str  ESTAB      0      0       * 17056                * 17112
    

    In the above example I have limited the output, on my server I have over 500 lines printed out by running the ss command, so you may wish to pipe it into something like less to easily read it, or otherwise append additional options on the end to only show what you’re after.

  • 2. Show Listening Sockets

    Rather than listing all sockets, we can use the -l option to specifically list the sockets that are currently listening for a connection.

    [root@centos7 ~]# ss -lt
    State       Recv-Q Send-Q  Local Address:Port                Peer Address:Port
    LISTEN      0      2                   *:kerberos-adm        *:*
    LISTEN      0      128                 *:sunrpc              *:*
    LISTEN      0      5                   *:kpasswd             *:*
    LISTEN      0      10       192.168.1.14:domain              *:*
    LISTEN      0      10          127.0.0.1:domain              *:*
    LISTEN      0      5       192.168.122.1:domain              *:*
    LISTEN      0      128                 *:ssh                 *:*
    

    In this example we have also used the -t option to only list TCP, more on this later. In future examples you will see that we will combine multiple options like this in order to quickly filter down to what we’re after.

  • 3. Show Processes

    We can print out the process or PID number that owns a socket with the -p option.

    [root@centos7 ~]# ss -pl
    Netid  State      Recv-Q Send-Q Local Address:Port     Peer Address:Port
    tcp    LISTEN     0      128    :::http                :::*                 users:(("httpd",pid=10522,fd=4),("httpd",pid=10521,fd=4),("httpd",pid=10520,fd=4),("httpd",pid=10519,fd=4),("httpd",pid=10518,fd=4),("httpd",pid=10516,fd=4))
    

    In the above example I have only listed a single result, without any further options the full output of ss prints out over 500 lines to stdout. Regardless, we can see the process ID’s of the various Apache processes that are running on this server.

  • 4. Don’t Resolve Service Names

    By default ss will only resolve port numbers as we have previously seen, for example in the line below we can see 192.168.1.14:ssh where ssh is listed as the local port.

    [root@centos7 ~]# ss
    Netid  State      Recv-Q Send-Q Local Address:Port    Peer Address:Port
    tcp    ESTAB      0      64     192.168.1.14:ssh      192.168.1.191:57091
    

    However if we specify the -n option, this resolution will not take place and we will instead see the port number rather than the service name.

    [root@centos7 ~]# ss -n
    Netid  State      Recv-Q Send-Q Local Address:Port    Peer Address:Port
    tcp    ESTAB      0      0      192.168.1.14:22       192.168.1.191:57091
    

    Note that :22 is now displayed rather than :ssh as we have disabled all name resolution of hostnames and ports. You can check the /etc/services file to see a full list of which ports map to which services.

  • 5. Resolve Numeric Address/Ports

    We can also do the opposite of this and resolve both the IP address and port number with the -r option. With this we now see the hostname of the 192.168.1.14 server listed.

    [root@centos7 ~]# ss -r
    Netid  State      Recv-Q Send-Q Local Address:Port         Peer Address:Port
    tcp    ESTAB      0      64     centos7.example.com:ssh    192.168.1.191:57091
    
  • 6. IPv4 Sockets

    We can use the -4 option to only display information corresponding to IPv4 sockets. In the below example we also make use of the -l option to list everything listening on an IPv4 address.

    [root@centos7 ~]# ss -l4
    Netid  State      Recv-Q Send-Q     Local Address:Port        Peer Address:Port
    udp    UNCONN     0      0              127.0.0.1:323         *:*
    udp    UNCONN     0      0          192.168.122.1:domain      *:*
    udp    UNCONN     0      0               *%virbr0:bootps      *:*
    udp    UNCONN     0      0                      *:bootpc      *:*
    tcp    LISTEN     0      128                    *:sunrpc      *:*
    tcp    LISTEN     0      5          192.168.122.1:domain      *:*
    tcp    LISTEN     0      128                    *:ssh         *:*
    tcp    LISTEN     0      128            127.0.0.1:ipp         *:*
    tcp    LISTEN     0      100            127.0.0.1:smtp        *:*
    
  • 7. IPv6 Sockets

    Likewise, we can use the -6 option to only display information related to IPv6 sockets. In the below example we also make use of the -l option to list everything listening on an IPv6 address.

    [root@centos7 ~]# ss -l6
    Netid  State      Recv-Q Send-Q     Local Address:Port          Peer Address:Port
    udp    UNCONN     0      0                     :::ipv6-icmp     :::*
    udp    UNCONN     0      0                     :::22834         :::*
    udp    UNCONN     0      0                    ::1:323           :::*
    tcp    LISTEN     0      128                   :::sunrpc        :::*
    tcp    LISTEN     0      128                   :::http          :::*
    tcp    LISTEN     0      128                   :::ssh           :::*
    tcp    LISTEN     0      128                  ::1:ipp           :::*
    tcp    LISTEN     0      100                  ::1:smtp          :::*
    
  • 8. TCP Only

    The -t option can be used to display only TCP sockets. When combined with -l to only print out listening sockets we can see everything listening on TCP.

    [root@centos7 ~]# ss -lt
    State      Recv-Q Send-Q      Local Address:Port       Peer Address:Port
    LISTEN     0      128                     *:sunrpc     *:*
    LISTEN     0      5           192.168.122.1:domain     *:*
    LISTEN     0      128                     *:ssh        *:*
    LISTEN     0      128             127.0.0.1:ipp        *:*
    LISTEN     0      100             127.0.0.1:smtp       *:*
    LISTEN     0      128                    :::sunrpc    :::*
    LISTEN     0      128                    :::http      :::*
    LISTEN     0      128                    :::ssh       :::*
    LISTEN     0      128                   ::1:ipp       :::*
    LISTEN     0      100                   ::1:smtp      :::*
    
  • 9. UDP Only

    The -u option can be used to display only UDP sockets. As UDP is a connection-less protocol, simply running with only the -u option will display no output. We can instead combine this with the -a or -l option to see all listening UDP sockets, as shown below.

    [root@centos7 ~]# ss -ul
    State       Recv-Q Send-Q  Local Address:Port       Peer Address:Port
    UNCONN      0      0                   *:mdns       *:*
    UNCONN      0      0                   *:kpasswd    *:*
    UNCONN      0      0                   *:839        *:*
    UNCONN      0      0                   *:36812      *:*
    UNCONN      0      0       192.168.122.1:domain     *:*
    UNCONN      0      0        192.168.1.14:domain     *:*
    
  • 10. Unix Sockets

    The -x option can be used to display unix domain sockets only.

    [root@centos7 ~]# ss -x
    Netid  State      Recv-Q Send-Q Local Address:Port           Peer Address:Port
    u_str  ESTAB      0      0      @/tmp/.X11-unix/X0 27818     * 27817
    u_str  ESTAB      0      0      @/tmp/.X11-unix/X0 26656     * 26655
    u_str  ESTAB      0      0       * 28344                     * 26607
    u_str  ESTAB      0      0       * 24704                     * 24705
    u_str  ESTAB      0      0      @/tmp/.X11-unix/X0 25195     * 24086
    u_str  ESTAB      0      0      @/tmp/dbus-CRqRiw6V 28388    * 28693
    .
    
  • 11. Display All Information

    the -a option shows all, both listening and non-listening sockets. In the case of TCP this means established connections. This option is useful for combining with others, for instance to show all UDP sockets we can add -a, as by default with just the -u option we don’t see as much information.

    [root@centos7 ~]# ss -u
    Recv-Q Send-Q       Local Address:Port           Peer Address:Port
    0      0             192.168.1.14:56658          129.250.35.251:ntp
    
    [root@centos7 ~]# ss -ua
    State       Recv-Q Send-Q  Local Address:Port           Peer Address:Port
    UNCONN      0      0                   *:mdns           *:*
    UNCONN      0      0           127.0.0.1:323            *:*
    ESTAB       0      0        192.168.1.14:56658          129.250.35.251:ntp
    UNCONN      0      0                   *:21014          *:*
    UNCONN      0      0                   *:60009          *:*
    UNCONN      0      0       192.168.122.1:domain         *:*
    UNCONN      0      0            *%virbr0:bootps         *:*
    UNCONN      0      0                   *:bootpc         *:*
    UNCONN      0      0                 ::1:323           :::*
    UNCONN      0      0                  :::43209         :::*
    
  • 12. Show Socket Memory Usage

    The -m option can be used to display the amount of memory that each socket is using.

    [root@centos7 ~]# ss -ltm
    State      Recv-Q Send-Q                Local Address:Port       Peer Address:Port
    LISTEN     0      128                               *:sunrpc     *:*
      skmem:(r0,rb87380,t0,tb16384,f0,w0,o0,bl0)
    LISTEN     0      5                     192.168.122.1:domain     *:*
      skmem:(r0,rb87380,t0,tb16384,f0,w0,o0,bl0)
    LISTEN     0      128                               *:ssh        *:*
      skmem:(r0,rb87380,t0,tb16384,f0,w0,o0,bl0)
    LISTEN     0      128                       127.0.0.1:ipp        *:*
      skmem:(r0,rb87380,t0,tb16384,f0,w0,o0,bl0)
    LISTEN     0      100                       127.0.0.1:smtp       *:*
      skmem:(r0,rb87380,t0,tb16384,f0,w0,o0,bl0)
    
  • 13. Show Internal TCP Information

    We can request additional internal TCP information with the -i info option.

    [root@centos7 ~]# ss -lti
    State      Recv-Q Send-Q                Local Address:Port                        Peer Address:Port
    LISTEN     0      128                               *:sunrpc                                    *:*
      cubic rto:1000 mss:536 cwnd:10 lastsnd:373620 lastrcv:373620 lastack:373620
    LISTEN     0      5                     192.168.122.1:domain                                    *:*
      cubic rto:1000 mss:536 cwnd:10 lastsnd:373620 lastrcv:373620 lastack:373620
    LISTEN     0      128                               *:ssh                                       *:*
      cubic rto:1000 mss:536 cwnd:10 segs_in:2 lastsnd:373620 lastrcv:373620 lastack:373620
    LISTEN     0      128                       127.0.0.1:ipp                                       *:*
      cubic rto:1000 mss:536 cwnd:10 lastsnd:373620 lastrcv:373620 lastack:373620
    LISTEN     0      100                       127.0.0.1:smtp                                      *:*
      cubic rto:1000 mss:536 cwnd:10 lastsnd:373620 lastrcv:373620 lastack:373620
    

    Underneath each listening socket we can see additional information. Note that the -i option does not work with UDP, if you instead specify -u instead of -t this extra information will not be present.

  • 14. Show Summary

    We can see a quick overview of the statistics with the -s option.

    [root@centos7 ~]# ss -s
    Total: 1253 (kernel 1721)
    TCP:   13 (estab 1, closed 2, orphaned 0, synrecv 0, timewait 0/0), ports 0
    
    Transport Total     IP        IPv6
    *   1721      -         -
    RAW     1         0         1
    UDP     9         7         2
    TCP     11        6         5
    INET    21        13        8
    FRAG    0         0         0
    

    This quickly allows us to see things like the total number of established connections, as well as counts of each type of socket and whether IPv4 or IPv6 is in use.

  • 15. Filter Based On State

    We can specify the state of a socket to only print out sockets in this state. For example we can specify states including established, syn-sent, syn-recv, fin-wait-1, fin-wait-2, time-wait, closed, closed-wait, last-ack, listen and closing. The below example shows all established TCP connections. To generate this I was connected to the server by SSH and just loaded a web page from Apache. We can then see that the connections to Apache quickly change to time-wait.

    [root@centos7 ~]# ss -t state established
    Recv-Q Send-Q               Local Address:Port           Peer Address:Port
    0      64                     192.168.1.14:ssh         192.168.1.191:57091
    0      0              ::ffff:192.168.1.14:http   ::ffff:192.168.1.191:57373
    0      0              ::ffff:192.168.1.14:http   ::ffff:192.168.1.191:57372
    
    [root@centos7 ~]# ss -t state time-wait
    Recv-Q Send-Q               Local Address:Port           Peer Address:Port
    0      0              ::ffff:192.168.1.14:http   ::ffff:192.168.1.191:57373
    0      0              ::ffff:192.168.1.14:http   ::ffff:192.168.1.191:57372
    
  • 16. Filter Based On Port Number

    Filtering can also be performed to list all ports that are less than (lt), greater than (gt), equal to (eq), not equal to (ne), less than or equal to (le), or greater than or equal to (ge).

    For example, the below command shows all listening ports on port number 500 or below.

    [root@centos7 ~]# ss -ltn sport le 500
    State       Recv-Q Send-Q    Local Address:Port      Peer Address:Port
    LISTEN      0      128                   *:111       *:*
    LISTEN      0      5         192.168.122.1:53        *:*
    LISTEN      0      128                   *:22        *:*
    LISTEN      0      100           127.0.0.1:25        *:*
    LISTEN      0      128                  :::111       :::*
    LISTEN      0      128                  :::22        :::*
    LISTEN      0      100                 ::1:25        :::*
    

    For comparison we can perform the opposite, and view all ports greater than 500 with ‘gt’

    [root@centos7 ~]# ss -ltn sport gt 500
    State       Recv-Q Send-Q    Local Address:Port       Peer Address:Port
    LISTEN      0      128           127.0.0.1:631        *:*
    LISTEN      0      128                 ::1:631        :::*
    

    We can also filter based on items such as source or destination port, for example below we search for TCP sockets that have a source port (sport) of ssh.

    [root@centos7 ~]# ss -t '( sport = :ssh )'
    State       Recv-Q Send-Q       Local Address:Port         Peer Address:Port
    ESTAB       0      64             192.168.1.14:ssh        192.168.1.191:57091
    
  • 17. Show SELinux Context

    The -Z and -z options can be used to show the SELinux security context of a socket. In the example below we also use the -t and -l options to only list listening TCP sockets, with the -Z option we can also see the SELinux contexts.

    [root@centos7 ~]# ss -tlZ
    State      Recv-Q Send-Q     Local Address:Port     Peer Address:Port
    LISTEN     0      128                    *:sunrpc     *:*                users:(("systemd",pid=1,proc_ctx=system_u:system_r:init_t:s0,fd=71))
    LISTEN     0      5          192.168.122.1:domain     *:*                users:(("dnsmasq",pid=1810,proc_ctx=system_u:system_r:dnsmasq_t:s0-s0:c0.c1023,fd=6))
    LISTEN     0      128                    *:ssh        *:*                users:(("sshd",pid=1173,proc_ctx=system_u:system_r:sshd_t:s0-s0:c0.c1023,fd=3))
    LISTEN     0      128            127.0.0.1:ipp        *:*                users:(("cupsd",pid=1145,proc_ctx=system_u:system_r:cupsd_t:s0-s0:c0.c1023,fd=12))
    LISTEN     0      100            127.0.0.1:smtp       *:*                users:(("master",pid=1752,proc_ctx=system_u:system_r:postfix_master_t:s0,fd=13))
    
  • 18. Display Version

    The -v option can be used to display specific version information for the ss command, in this instance we see the version of the iproute package which provides ss.

    [root@centos7 ~]# ss -v
    ss utility, iproute2-ss130716
    
  • 19. Print Help Documentation

    The -h option can be used to display further help regarding the ss command, it’s good to use as a quick reference if you need a short description on some of the most commonly used options. Note that the full output here has not been included for brevity.

    [root@centos7 ~]# ss -h
    Usage: ss [ OPTIONS ]
    
  • 20. Show Extended Information

    We can use the -e option which shows extended detailed information, as shown below we can see the extended information appended to the end of each line.

    [root@centos7 ~]# ss -lte
    State      Recv-Q Send-Q      Local Address:Port         Peer Address:Port
    LISTEN     0      128                     *:sunrpc       *:*                 ino:16090 sk:ffff880000100000 <->
    LISTEN     0      5           192.168.122.1:domain       *:*                 ino:23750 sk:ffff880073e70f80 <->
    LISTEN     0      128                     *:ssh          *:*                 ino:22789 sk:ffff880073e70000 <->
    LISTEN     0      128             127.0.0.1:ipp          *:*                 ino:23091 sk:ffff880073e707c0 <->
    LISTEN     0      100             127.0.0.1:smtp         *:*                 ino:24659 sk:ffff880000100f80 <->
    
  • 21. Show Timer Information

    The -o option can be used to display the timer information. This information shows us things such as the retransmission timer value, number of retransmissions that have occurred, and the number of keepalive probes that have been sent.

    [root@centos7 ~]# ss -to
    State       Recv-Q Send-Q         Local Address:Port             Peer Address:Port
    ESTAB       0      64              192.168.1.14:ssh              192.168.1.191:57091      timer:(on,242ms,0)
    ESTAB       0      0        ::ffff:192.168.1.14:http      ::ffff:192.168.1.191:57295      timer:(keepalive,120min,0)
    ESTAB       0      0        ::ffff:192.168.1.14:http      ::ffff:192.168.1.191:57296      timer:(keepalive,120min,0)
    

در لینومس دسترسی کامل با دو روش زیر امکان پذیر است:
  1. su
  • نیاز به پسورد روت می‌باشد
  • معمولا دسترسی به یوزر روت در هیچ سازمانی صورت نمیگیرد
  • نمی‌توانیم متوجه شویم که یوزرهای سیستم چکار کرده اند چون همه با یوزر روت کارهایشان را انجام داده اند
  • sudo
    • در مسیر /var/log/auth.log  فعالیت های صورت گرفته لاگ می‌شود.

    به دو صورت میتوان یک یوزر را sudo نماییم:

    1. فایل /etc/sudoers
    2. عضویت در گروه

    روش اول:

    فایل زیر را ادیت کرده و خط زیر را در آن قرار دهید:

    # vim /etc/sudoers(or sudo visudo)
    behrooz ALL=(ALL) ALL

    در خط بالا که به فایل /etc/sudoers اضافه میشود behrooz نام یوزر است


        behrooz indicates user name
        First ALL instructs to permit sudo access from any terminal/machine
        Second (ALL) instructs sudo command to be allowed to execute as any user
        Third ALL indicates all command can be executed as root

    روش دوم:
    در فایل /etc/sudoes یک گروه معرفی شده است که اگر کسی در آن عضو شود به این منزله است که روش اول را در فایل /etc/sudoers انجام داده ایم-
    نکته: در توزیع های کنونی دبیان نام این گروه sudo و در توزیع های کنونی redHat نام این گروه wheel است.
    نکته: برای این که یک یوزر را به گروه جدید اضافه نماییم از روش زیر استفاده می‌شود:
    sudo usermod -aG UserName GroupName









    select
    case
    when b.table_name is null then
    'unindexed'
    else
    'indexed'
    end as status,
    a.table_name as table_name,
    a.constraint_name as fk_name,
    a.fk_columns as fk_columns,
    b.index_name as index_name,
    b.index_columns as index_columns
    from
    (
    select
    a.table_name,
    a.constraint_name,
    listagg(a.column_name, ',') within
    group (order by a.position) fk_columns
    from
    dba_cons_columns a,
    dba_constraints b
    where
    a.constraint_name = b.constraint_name
    and
    b.constraint_type = 'R'
    and
    a.owner = '&&schema_owner'
    and
    a.owner = b.owner
    group by
    a.table_name,
    a.constraint_name
    ) a
    ,(
    select
    table_name,
    index_name,
    listagg(c.column_name, ',') within
    group (order by c.column_position) index_columns
    from
    dba_ind_columns c
    where
    c.index_owner = '&&schema_owner'
    group by
    table_name,
    index_name
    ) b
    where
    a.table_name = b.table_name(+)
    and
    b.index_columns(+) like a.fk_columns || '%'
    order by
    1 desc, 2;

    برای نصب برنامه pycharm که یک ادیتور هست که  کد پایتون را کامپایل میکند به روش زیر عمل میکنیم(نصب در دبیان9)
    نکته: از لینک آخر این دایکومنت برای نصب در توزیع‌های دیگر نیز میتوانید استفاده نمایید

    گام اول: بارگردن آدرس 

    URL

    گام دوم: instal this package

    گام سوم: select opration sysstem

    گام چهارم:  select server to download

    گام پنجم:

    sudo apt-get install pycharm-community-sloppy




    اسکرین برای بوجود آوردن چند session  در bash کاربرد دارد اگر بخواهیم از یک ترمینال جندین ترمینال مشتق شود بطوری که هرکدام مستقلا باشند و درصورت بسته شدن آنها(detach)، کارشان مختل نشود، از screen  استفاده میکنیم:
    نکته : تقریبا در تمامی دستورات اسکرین از دستور کلید ترکیبی ctrl به همراه a  به همراه کلید دیگری استفاده میشود.
    برای ایجاد یک اسکرین از دستور زیر استفاده می‌شود(در بش اصلی):
    sudo apt-get install screen
    sudo yum install screen

    screen -S NAME
    برای برگشتن به bash  اصلی(detach شدن اسکرین ایجاد شده که در آن بودیم-این دستور را باید در محیط اسکرین بزنیم):
    ctrl+a, And d
     برای دیدن تمامی سشن های باز از اسکرین(در بش اصلی):
    screen -ls

    برای رفتن به یک اسکرین دلخواه(در بش اصلی)(reattach):
    screen -r NAME
    screen -x  NAME

    کشتن یک اسکرین(در بش اصلی):
    screen -S NAME -X quit
    کشتن یک اسکرین(در محیط اسکرین):
    ctrl+d
    رفتن به اسکرین بعدی(در محیط اسکرین)
    ctrl+a, And n
    رفتن به اسکرین قبلی(در محیط اسکرین)
    ctrl+a, And p
    نمایش تمام اسکرین های باز(در محیط اسکرین)
    ctrl+a, And "
    رفتن به اسکرین شماره خاص(در محیط اسکرین)
    ctrl+a, And 0-9
     
     

        Ctrl+a " to visualize the opened windows
        Ctrl+a p and Ctrl+a n to switch with the previous/next window
        Ctrl+a number to switch to the window number
        Ctrl+d to kill a window
        screen -ls to list the sessions and their status
        screen -S session_name to start a session with a given name. The name should be unique
        Ctrl+a d to detach a session
        screen -x session_name to resume (reattach) a session knowing its name
        screen -S session_name -X quit to terminate a detached session
     
    Layout:
        Ctrl+a S to split horizontally
        Ctrl+a | to split vertically
        Ctrl+a <Tab> to switch to the next region
        Ctrl+a X to close the current region
        Ctrl+a Q to close all the regions but the current one

      

    URL1
      

    URL2
      

    URL3



    deb http://site.example.com/debian distribution component1 component2 component3
    deb-src http://site.example.com/debian distribution component1 component2 component3


    deb: دانلود بسته هایی از جنس باینری که کامپایل شده است.

    deb-src: دانلود بسته هایی از جنس کد می‌باشد

    url:  لینک دانلود کردن بسته‌ها(here)

    Distribution: نام ورژن دبیان-(Buster دبیان10)(Stretch دبیان9)(Jessie دبیان8)(Stable مثلا داریم از دبیان9 استفاده میکنیم و میخواهیم وقتی دبیان10 آمد به آن سوییچ شود)

    components

    • main: بسته های شامل حوزه  DFSG شرکت دبیان که مخفف Debian Free Software Guidelines است. یعنی بسته هایخارج از این حوزه رسما توسط شرکت دبیان تایید نمی‌شوند. برنامه های که در حوزه DFSG  قرار دارند باید 10 مورد را رعایت نمایند(DFSG) نظیر ایگان باشند  و source code هم همراه داشته باشد قابلیت مشتق شدن یا استفاده از آن وجود داشته باشد و .
    • contrib: نرم افزار مطابق با ضوابط DFSG باشد اما چند وابستگی از آن نرم افزار ، DFSG را رعایت نکرده باشد ، در این صورت آن نرم افزار و وابستگی هایش در این گروه قرار می گیرند.(بسته هایی که شامل DFSG هستند ولی dependencies آنها در main قرار ندرد)
    • non-free: بسته‌هایی که کلا در حوزه DFSG قرار ندارند

    در زیر یک نمونه از فایل source.list که از سیستم عامل دبیان ۹ است آورده شده است:

    deb http://deb.debian.org/debian stretch main
    deb-src http://deb.debian.org/debian stretch main
    
    deb http://deb.debian.org/debian stretch-updates main
    deb-src http://deb.debian.org/debian stretch-updates main
    
    deb http://security.debian.org/debian-security/ stretch/updates main
    deb-src http://security.debian.org/debian-security/ stretch/updates main

    نکته: اگر بخواهید از بسته‌های contrib و non-free استفاده نمایید، می‌توانید پس از main یک فاصله گذاشته و به ترتیب عبارت  contrib  و  non-free را تایپ نمایید

    نکته:  اگر بخواهید موارد بالا را به حالت گرافیکی تنظیم نمایید از دستور زیر استفاده نمایید:

    sudo gksu --desktop /usr/share/applications/software-properties.desktop /usr/bin/software-properties-gtk



    جستجو در عبارت است نظیر grep  در لینوکس

    ipconfig  | findstr IP

    تمام اطلاعات از کارت شبکه:

    ipconfig /all

    DNS های لوکال cache شده در سیستم

    ipconfig /displaydns

    پاک کردنDNS های لوکال cache شده در سیستم


    ipconfig /flushdns

    نمایش اطلاعات جامع از سیستم

    systeminfo

    لیستی مشابه تسک منیجر ارائه میدهد

    tasklist

    بستن یک برنامه بر اساس پروسس آی دی

    taskkill /PID NUMBER

    نمایش متن یک فایل متنی

    type  FILE.txt

    وضعیت و اطلاعات سوکت‌ها و پورت‌ها و کانکشن‌های سیسیتم را نشان میدهد

    netstat -a

    برای start ویا stop کردن سرویس‌ها از دستور زیر استفاده میشود:

    net start  SERVICE

    net stop SERVICE

    برای افزودن یک درارو شبکه‌ای ویا حذف آن از دستور زیر استفاده میشود

    net use m: \myserversharename
    net use m: \myserversharename /delete

    نکته:دستور net بسیار کارهای دیگر نیز میتواتند انجام دهد که شرح آن را در help آن مشاهده نمایید.

    برای اینکه ببینید dns پیش فرض شما چه می‌باشد از دستور nslookup استفاده نمایید

    nslookup

    برای تغییر  dns از پیش‌فرض به یک سرور دیگر  ابتدا دستور nslookup را زده و سپس دستور set  ds وارد کرده و اینتر را بزنید و سپس آدرس ip دی ان اس سرور مورد نظر را وارد نمایید.

    nslookup

    set ds

    8.8.8.8

    ااستفاده از دی ان اس برای پیدا کردن IP یک دامنه:
    nslookup NAME
    ااستفاده از دی ان اس برای پیدا کردن IP یک دامنه با استفاده از dns Server دلخواه8.8.8.8:

    nslookup NAME 8.8.8.8.

    برای تغییردر group policy
    gpresult

    لینک مفید



    مشاهده اطلاعاتی نظیر رم و هارد و سریال پورت و یو اس بی
    dmesg | grep -E "memory|dma|usb|tty"



    پاک کردن پیغام های موجود برای دوری از شلوغی خروجی:
    dmesg -C



     مشاهده خروجی بصورت رنگ بندی شده به جهت وضوح بیشتر
    dmseg  -L



    تنها یک سطح خاص از مطالب را نمایش بدهد(emerg,alert, crit, err, warn,notice,info,debug)
    dmesg --level=err,warn



    نمایش تایم در لاگ
    dmesg -T
    dmesg -Tx



    بصورت real time  لاگ‌ها را مشاهده نمایید
    dmesg --follow



    مشاهده پیغام های بافر شده(لاگ کارهایی که هنوز مانده است تا انجام بشود و خروجی عمل به مرحله ظهور نرسیده است)
    dmesg -r  #raw message buffer



    اگر بخواهیم برنامه dmesg را اجبار کنیم که از فایل های syslog هم بخواند(مثلا فایل /dev/kmsg. را هم بخواند)
    dmesg -S


    نکته: دستورات dmesg از فایل /var/log/dmesg”  خوانده میشود.

    ترتیب خوانده شدن فایل های کانفیگی در  دبیان 9:


    20180430-155851-Profile:begin (اجرا در اول)

    20180430-155851-profile:End (اجرا در دومین مرحله)

    20180430-155915-bashrc:begin (اجرا در سومین مرحله)

    20180430-155915-bash_alias:begin (اجرا در چهارمین مرحله)

    20180430-155915-bash_alias:End (اجرا در پنجمین مرحله)

    20180430-155915-bashrc:end (اجرا در ششمین مرحله)


    مقایسه میزان رم با استفاده از دو دستور:   free -m  و cat /proc/meminfo




    /proc/meminfo(KB) free -k Status
    MemTotal 4040208 4040208 Equal
    MemFree 518032 518016 Equal
    MemAvailable 1582984 1582968 Equal
    used
    2116340 Total – (free + cache + buffer)
    Buffers 94508 1405852 Equal
    Cached 1218532
    SwapTotal 9867260 9867260 Equal
    SwapFree 9867260 9867260 Equal
    swap used
    0
    Shmem 91388 91388 Equal

    tar:

    archive: tar -cvf File.tar /directory

    Extract: tar xf FileName.tar


    Tar.gz:

    Archive: tar czvf name.tar.gz files

    Extract: tar xzvf name.tar.gz


    tar.bz2:

    Archive: tar -cvjSf folder.tar.bz2 folder

    Extract: tar xjf File.tar.bz2 


    bz2:

    Archive: bzip2 -z filename

    [or] Archive: bzip2  filename

    Extract: bunzip2 FileName.bunzip2

    [or] Extract: bzip2 -d filename.bz2


    rar:

    archive: 

    Extract: unrar e FileName.rar

     

    gz:

    Archive: gzip file

    Extract: gzip -d file.gz

    Extract: gunzip FileName.gz


    zip:

    archive: zip file.zip file

    archive: zip -r Folder.zip folder

    Extract: unzip File.zip


    7zip:

    Archive: 7z a File.7z File

    Extract: 7z e File.7z


    • نمایش اطلاعات سروری که در آن برنامه VirtualBox در حال اجرا می‌باشد

    vboxmanage list hostinfo

    • نمایش لیست وی ام های موجود در سرور

    vboxmanage list vms

    • نمایش لیست وی ام های موجود در سرور با اطلاعات کامل

    vboxmanage list vms --long

    • نمایش لیست وی ام های روشن در سرور

    vboxmanage list runningvms 

    • نمایش لیست وی ام های روشن در سرور با اطلاعات کامل

    vboxmanage list runningvms --long

    • نمایش تمامی اطلاعات یک وی ام برحسب نام یا uuid

    vboxmanage showvminfo {UUID}

    • روشن کردن یک وی ام در حالت headless

    vboxheadless --startvm {UUID}

    • توقف در وضعیت یا pause  یک وی ام

    vboxmanage controlvm {UUID} savestate

    • خاموش کردن یک وی ام

    vboxmanage controlvm {UUID} acpipowerbutton


    1. sudo mkdir -p  /media/repo1 /media/repo2  /media/repo3 /opt/DVD
    2. sudo chown -R USERNAME:USERNAME /opt
    3. sudo chmod -R 755 /opt
    4. Copy All DVDs in Directory: /opt/DVD
    5. sudo vim /etc/fstab:
      1. /opt/dvd/debian-9.5.0-i386-DVD-1.iso /media/repo1 iso9660 defaults 0 0
      2. /opt/dvd/debian-9.5.0-i386-DVD-2.iso /media/repo1 iso9660 defaults 0 0
      3. /opt/dvd/debian-9.5.0-i386-DVD-3.iso /media/repo1 iso9660 defaults 0 0
    6. sudo vim /etc/apt/sources.lists:
      1. deb [trusted=yes] file:///media/repo1 stretch main contrib
      2. deb [trusted=yes] file:///media/repo2 stretch main contrib
      3. deb [trusted=yes] file:///media/repo3 stretch main contrib

    Show address:

    ip: show commands:

    • ip help ---> #Display ip commands and arguments
    • ip -4 a ---> #Only show TCP/IP IPv4
    • ip -6 a ---> #Only show TCP/IP IPv6
    • ip a list eth0 ---> #Only show eth0 interface
    • ip a show dev eth0 ---> #Only show eth0 interface
    • ip a show eth0 ---> #Only show eth0 interface

    addr: Display IP Addresses and property information(abbreviation of address)

    • ip addr ---> #Show information for all addresses
    • ip addr help ---> #Display address commands and arguments
    • ip addr show dev eth0 ---> #Display information only for device

    link: Manage and display the state of all network interfaces

    • ip link help ---> #Display link commands and arguments
    • ip link ls up ---> #Only show running interfaces
    • ip link show dev eth0 ---> #Display information only for device eth0
    • ip link ---> #Show information for all interfaces
    • ip -s link ---> #Display interface statistics
    • ip -s -s link ls eth0 ---> #get information about a particular network interface
    • ip link set eth0 up ---> #Bring eth0 online
    • ip link set eth0 down ---> #Bring eth0 offline
    • ip link set eth0 promisc on ---> #Enable promiscuous mode for eth0

    Add or Delete Address:

    • ip a add {ip_addr/mask} dev {interface} ---> #The syntax is as follows to add an IPv4/IPv6 address
    • ip a del {ipv6_addr_OR_ipv4_addr} dev {interface} ---> The syntax is as follows to remove an IPv4/IPv6 address:
    • ip addr add 192.168.1.1/24 dev eth0           ---> #Add address 192.168.1.1 with netmask 24 to device eth0
    • ip a add 192.168.1.200/255.255.255.0 dev eth0 ---> To assign 192.168.1.200/255.255.255.0 to eth0
    • ip a add 192.168.1.200/24 dev eth0 ---> To assign 192.168.1.200/255.255.255.0 to eth0
    • ip addr del 192.168.1.1/24 dev eth0           ---> #Remove address 192.168.1.1/24 from device eth0
    • ip a del 192.168.1.200/24 dev eth0 ---> To delete 192.168.1.200/24 from eth0



    neigh

    neigh : ARP, Show neighbour objects; also known as the ARP table for IPv4

    • ip neigh                                  ---> #Display neighbour objects(Show neighbour objects; also known as the ARP table for IPv4)
    • ip neigh help                               ---> #Display neighbour commands and arguments
    • ip neighbour                                  ---> #View the MAC address of the devices connected in your LAN
    • ip neigh show dev eth0                                      ---> #Show the ARP cache for device eth0
    • ip neigh add 192.168.1.1 lladdr 1:2:3:4:5:6 dev eth0      ---> #Add address 192.168.1.1 with MAC 1:2:3:4:5:6 to eth0
    • ip neigh del 192.168.1.1 dev eth0                                   ---> #Invalidate the entry for 192.168.1.1 on eth0
    • ip neigh replace 192.168.1.1 lladdr 1:2:3:4:5:6 dev eth0 ---> #Replace the entry for address 192.168.1.1 to use MAC 1:2:3:4:5:6 on eth0
    • ip n show                                                                        ---> #Display neighbour/arp cache
    • ip neigh show                                                                  ---> #Display neighbour/arp cache

    Sample outputs (note: masked out some data with alphabets):

    74.xx.yy.zz dev eth1 lladdr 00:30:48:yy:zz:ww REACHABLE

    10.10.29.66 dev eth0 lladdr 00:30:48:c6:0a:d8 REACHABLE

    74.ww.yyy. dev eth1 lladdr 00:1a:30:yy:zz:ww REACHABLE

    10.10.29.68 dev eth0 lladdr 00:30:48:33:bc:32 REACHABLE

    74.fff.uu.cc dev eth1 lladdr 00:30:48:yy:zz:ww STALE

    74.rr.ww.fff dev eth1 lladdr 00:30:48:yy:zz:ww DELAY

    10.10.29.65 dev eth0 lladdr 00:1a:30:38:a8:00 REACHABLE

    10.10.29.74 dev eth0 lladdr 00:30:48:8e:31:ac REACHABLE


    The last field show the the state of the neighbour unreachability detection” machine for this entry:

    STALE – The neighbour is valid, but is probably already unreachable, so the kernel will try to check it at the first transmission.

    DELAY – A packet has been sent to the stale neighbour and the kernel is waiting for confirmation.

    REACHABLE – The neighbour is valid and apparently reachable.


    Add a new ARP entry:

    • ip neigh add {IP-HERE} lladdr {MAC/LLADDRESS} dev {DEVICE} nud {STATE}     ---> #syntax is
    • ip neigh add 192.168.1.5 lladdr 00:1a:30:38:a8:00 dev eth0 nud perm         ---> #add a permanent ARP entry for the neighbour 192.168.1.5 on the device eth0:

    neighbour state (nud):

    permanent The neighbour entry is valid forever and can be only be removed administratively

    noarp The neighbour entry is valid. No attempts to validate this entry will be made but it can be removed when its lifetime expires.

    stale The neighbour entry is valid but suspicious. This option to ip neigh does not change the neighbour state if it was valid and the address is not changed by this command.

    reachable The neighbour entry is valid until the reachability timeout expires.

    Delete a ARP entry:

    • ip neigh del {IPAddress} dev {DEVICE}        ---> #Syntax
    • ip neigh del 192.168.1.5 dev eth1         ---> #invalidate or delete an ARP entry for the neighbour 192.168.1.5 on the device eth0

    Change ARP state:

    • ip neigh chg 192.168.1.100 dev eth1 nud reachable ---> #TO REACHABLE FOR THE NEIGHBOUR 192.168.1.100 ON THE DEVICE ETH1:




    Route

    Route:Display and alter the routing table

    • ip route       ---> #List all of the route entries in the kernel[routing tables]
    • ip route show                                                            ---> #check the routing table information of the system
    • ip route add default via 192.168.1.1 dev eth0         ---> #Add a default route (for all addresses) via the local gateway 192.168.1.1 that can be reached on device eth0
    • ip route add 192.168.1.0/24 via 192.168.1.1            ---> #Add a route to 192.168.1.0/24 via the gateway at 192.168.1.1
    • ip route add 192.168.1.0/24 dev eth0                      ---> #Add a route to 192.168.1.0/24 that can be reached on device eth0
    • ip route del default via 192.168.1.1                          ---> #delete default gateway                                     
    • ip route delete 192.168.1.0/24 via 192.168.1.1       ---> #Delete the route for 192.168.1.0/24 via the gateway at 192.168.1.1
    • ip route replace 192.168.1.0/24 dev eth0                ---> #Replace the defined route for 192.168.1.0/24 to use device eth0
    • ip route get 192.168.1.5                                            ---> #Display the route taken for IP 192.168.1.5
    • ip r                                             ---> #display the contents of the routing tables
    • ip r list                                  ---> #display the contents of the routing tables
    • ip route list                                ---> #display the contents of the routing tables
    • ip r list 192.168.1.0/24         ---> #Display routing for 192.168.1.0/24

    output:192.168.1.0/24 dev eth1  proto kernel  scope link  src 192.168.1.10


    Add a new route:

    • ip route add {NETWORK/MASK} via {GATEWAYIP} ---> #The syntax is
    • ip route add {NETWORK/MASK} dev {DEVICE} ---> #The syntax is
    • ip route add default {NETWORK/MASK} dev {DEVICE} ---> #The syntax is
    • ip route add default {NETWORK/MASK} via {GATEWAYIP} ---> #The syntax is
    • ip route add 192.168.1.0/24 via 192.168.1.254     ---> #Add a plain route to network 192.168.1.0/24 via gateway 192.168.1.254
    • ip route add 192.168.1.0/24 dev eth0     ---> #To route all traffic via 192.168.1.254 gateway connected via eth0 network interface

    Delete a route:

    • ip route del default                      ---> #The syntax is[as follows to delete default gateway]
    • ip route del 192.168.1.0/24 dev eth0         ---> #In this example, delete the route created in previous subsection:



    Disable [or] flush:

    This flush or f command flushes neighbour/arp tables, by specifying some condition.

    • ip -s -s n f {IPAddress}                    ---> #The syntax is
    • ip -s -s n f 192.168.1.5                        ---> #In this example, flush neighbour/arp table
    • ip -s -s n flush 192.168.1.5                  ---> #In this example, flush neighbour/arp table
    • ip -4 addr flush label "ppp*"        ---> #disable IP address on all the ppp (Point-to-Point) interfaces
    • ip -4 addr flush label "eth*"                     ---> #Here is another example for all the Ethernet interfaces
    • ip -s -s a f to 192.168.2.0/24                    --->  #Delete all the IP addresses from the private network (For example) 192.168.2.0/24

    output:

    2: eth0    inet 192.168.2.201/24 scope global secondary eth0

    2: eth0    inet 192.168.2.200/24 scope global eth0

    *** Round 1, deleting 2 addresses ***

    *** Flush is complete after 1 round ***



    Txqueuelen

    set the length of the transmit queue of the device using  ip command as follows:

    • ip link set txqueuelen {NUMBER} dev {DEVICE}    --->   # Syntax
    • ip link set txqueuelen 10000 dev eth0              ---> #change the default txqueuelen from 1000 to 10000 for the eth0
    • ip a list eth0



    MTU

    For gigabit networks, set maximum transmission units (MTU) sizes (JumboFrames) for better network performance. The syntax is:
    • ip link set mtu {NUMBER} dev {DEVICE}            ---> #Syntax
    • ip link set eth0 mtu 9000           ---> #Set the MTU on eth0 to 9000
    • ip link set mtu 9000 dev eth0              ---> #To change the MTU of the device eth0 to 9000
    • ip a list eth0

    Sample outputs:

    2: eth0:  mtu 9000 qdisc pfifo_fast state UP qlen 1000

        link/ether 00:08:9b:c4:30:30 brd ff:ff:ff:ff:ff:ff

        inet 192.168.1.10/24 brd 192.168.1.255 scope global eth1

        inet6 fe80::208:9bff:fec4:3030/64 scope link 

           valid_lft forever preferred_lft forever




    Broadcast:

    Notice:By default, the ip command does not set any broadcast address unless explicitly requested

    • ip addr add brd {ADDDRESS-HERE} dev {interface}          ---> #ADDING THE BROADCAST ADDRESS ON THE INTERFACE
    • ip addr add broadcast {ADDDRESS-HERE} dev {interface} ---> #ADDING THE BROADCAST ADDRESS ON THE INTERFACE
    • ip addr add broadcast 172.20.10.255 dev eth0       ---> #add 172.20.10.255 as broadcast on eth0


    Multicast

    maddr: Manage and display multicast IP addresses

    • ip maddr ---> #Display multicast information for all devices
    • ip maddr show dev eth0 ---> #Display multicast information for device eth0




    OLD and NEW Commands:

    • arp -a -----> ip neigh
    • arp -v -----> ip -s neigh
    • arp -s 192.168.1.1 1:2:3:4:5:6 -----> ip neigh add 192.168.1.1 lladdr 1:2:3:4:5:6 dev eth1
    • arp -i eth1 -d 192.168.1.1 -----> ip neigh del 192.168.1.1 dev eth1
    • ifconfig -a -----> ip addr
    • ifconfig eth0 down -----> ip link set eth0 down
    • ifconfig eth0 up -----> ip link set eth0 up
    • ifconfig eth0 192.168.1.1 -----> ip addr add 192.168.1.1/24 dev eth0
    • ifconfig eth0 netmask 255.255.255.0 -----> ip addr add 192.168.1.1/24 dev eth0
    • ifconfig eth0 mtu 9000 -----> ip link set eth0 mtu 9000
    • ifconfig eth0:0 192.168.1.2 -----> ip addr add 192.168.1.2/24 dev eth0
    • netstat -g -----> ip maddr
    • route -----> ip route
    • route add -net 192.168.1.0 netmask 255.255.255.0 dev eth0 -----> ip route add 192.168.1.0/24 dev eth0
    • route add default gw 192.168.1.1 -----> ip route add default via 192.168.1.1


    Abbreviation:

    Object Abbreviated form Purpose
    • link ----> l ----> Network device.
    • address ----> a [or] addr ----> Protocol (IP or IPv6) address on a device.
    • addrlabel ----> addrl ----> Label configuration for protocol address selection.
    • neighbour ----> n [or] neigh ----> ARP or NDISC cache entry.
    • route ----> r ----> Routing table entry.
    • rule ----> ru ----> Rule in routing policy database.
    • maddress ----> m [or] maddr ----> Multicast address.
    • mroute ----> mr ----> Multicast routing cache entry.
    • tunnel ----> t ----> Tunnel over IP.
    • xfrm ----> x ----> Framework for IPsec protocol.


    URL1


    1-show gateway(s):

    • route
    • route -n
    • ip route show
    • ip route list


    Add route:

    • route add default gw {IP-ADDRESS(router IP)} {INTERFACE-NAME}
    • route add default gw 192.168.1.254 eth0                            #Route all traffic via 192.168.1.254 gateway connected via eth0 network interface:
    • ip route add 192.168.1.0/24 dev eth0                                        #to route all traffic via 192.168.1.254 gateway connected via eth0 network interface:
    • ip route add 192.168.1.0/24 via 192.168.1.254                         #to route all traffic via 192.168.1.254 gateway connected via eth0 network interface:

    Delete rout

    • ip route del default via 192.168.122.1 dev eth0

    GUI(set configuration from ui)

    • redhat-config-network                            #if your are using Red Hat/CentOS/Fedora core Linux type this
    • network-admin #If you are using other Linux distribution use this

    1. nslookup domain.ir [#Finding The IP Address of an Host from default dns server]
    2. nslookup domain.ir 8.8.8.8[#Finding The IP Address of an Host From non default dns server]
    3. nslookup -querytype=mx domain.ir[ #Find Mail Servers for a Domain]
    4. nslookup -query=mx domain.ir [#Find Mail Servers]
    5. nslookup -query=ns domain.ir [ #Find NameServers]
    6. nslookup -query=soa domain.ir [ #display the SOA record (information about the domain]
    7. nslookup -query=any domain.ir [ #display all the available DNS records]


      DISM /Online /Enable-Feature /FeatureName:NetFx3 /All /LimitAccess /Source:d:\sources\sxs
      • d:\                  [the drive that the Windows Server ISO has mounted]
      • /All                [enable all parent features of the specified feature]
      • /LimitAccess [prevent DISM from contacting Windows Update/WSUS]
      • /Source          [specify the location of the files that are needed to restore the feature]

      URL


      SELinux stands for Security-Enhanced Linux. It is a way to improve the server security.


      cat /etc/selinux/config 
      # This file controls the state of SELinux on the system.
      # SELINUX= can take one of these three values:
      #     enforcing - SELinux security policy is enforced.
      #     permissive - SELinux prints warnings instead of enforcing.
      #     disabled - No SELinux policy is loaded.
      SELINUX=enforcing
      # SELINUXTYPE= can take one of three two values:
      #     targeted - Targeted processes are protected,
      #     minimum - Modification of targeted policy. Only selected processes are protected. 
      #     mls - Multi Level Security protection.
      SELINUXTYPE=targeted

      Show state:

      • $ sestatus       #show state
      • $ getenforce   #show state]

      change[not permanent]:

      • $ setenforce [enforcing] or [permissive]      

      Change Permanently:

      vim /etc/selinux/config
      SELINUX=enforcing


      URL


      • modprobe rt2800usb #Load module in kernel
      • modprobe -r rt2800usb #remove module from kernel
      • or  [rmmod rt2800usb] #remove module from kernel
      •  lsmod | grep rt2800 #check is load


      Permanent load modules:

      vim /etc/modules-load.d/rt2800usb.conf

      • rt2800usb #add this line
      Check if systemd service loaded the module:

      • systemctl status systemd-modules-load.service

      The output should look like this:


      systemd-modules-load.service - Load Kernel Modules
        Loaded: loaded (/usr/lib/systemd/system/systemd-modules-load.service; static)
        Active: active (exited) since Wed, 03 Apr 2013 22:50:57 +0000; 46s ago
              Docs: man:systemd-modules-load.service(8)
                    man:modules-load.d(5)
       Process: 260 ExecStart=/usr/lib/systemd/systemd-modules-load (code=exited, status=0/SUCCESS)

        if status=1/FAILURE

       journalctl -b

      URL


      Socket States


      CLOSED 

      • Indicates that the server has received an ACK signal from the client and the connection is closed


      CLOSE_WAIT 

      • Indicates that the server has received the first FIN signal from the client and the connection is in the process of being closed
      • So this essentially means that his is a state where socket is waiting for the application to execute close()
      • A socket can be in CLOSE_WAIT state indefinitely until the application closes it. 
      • Faulty scenarios would be like filedescriptor leak, server not being execute close() on socket leading to pile up of close_wait sockets


      ESTABLISHED 

      Indicates that the server received the SYN signal from the client and the session is established


      FIN_WAIT_1 

      • Indicates that the connection is still active but not currently being used


      FIN_WAIT_2 

      • Indicates that the client just received acknowledgment of the first FIN signal from the server


      LAST_ACK 

      • Indicates that the server is in the process of sending its own FIN signal


      LISTENING 

      • Indicates that the server is ready to accept a connection


      SYN_RECEIVED 

      • Indicates that the server just received a SYN signal from the client


      SYN_SEND 

      • Indicates that this particular connection is open and active


      TIME_WAIT 

      • Indicates that the client recognizes the connection as still active but not currently being used

      option:

      -i This installs a new package(rpm -i package)

      -F This will upgrade packages, but only if an earlier version currently exists(rpm -F package)

      -U This upgrades or installs the package currently installed to a newer version(rpm -U package)

      -e erase (uninstall) package(rpm -e package)

      -q query packages(rpm -q package)

      -V verify installed packages(rpm -V package)

      -K verify package signature(rpm -K package)

      --rebuilddb rebuild the database indices from the installed package headers(rpm --rebuilddb)

      --initdb create a new database if one doesn’t already exist(rpm --initdb)

      --import import PUBKEY(rpm --import /usr/share/rhn/RPM-GPG-KEY)


      options with i, U:

      -v show package name(rpm -iv package)

      -h display progress(rpm -ivh package)

      -vv Print lots of ugly debugging information(rpm -ivv package)

      --nodeps Don’t do a dependency check before installing or upgrading a package(rpm -ivh --nodeps package)

      --test Don’t really uninstall anything, just go through the motions(rpm -ivh --test package)


      options with q:

      -a Query all installed packages(rpm -qa)

      -i Display package information, including name, version, and description. This uses the --queryformat if one was specified(rpm -qi) package

      -l List files in package(rpm -ql package)

      -c List only configuration files (implies -l)(rpm -qc package)

      -d List only documentation files (implies -l)(rpm -qd package)

      -f Query package owning FILE(rpm -qf /bin/bash)

      -R List packages on which this package depends(rpm -qR package)

      -s Display the states of files in the package (implies -l)(rpm -qs package)

      --last Orders the package listing by install time such that the latest packages are at the top(rpm -q --last package)

      --changelog Display change information for the package(rpm -q --changelog package)


      URL

      برای اطلاع پیدا کردن از اطلاعات ساختاری و تعداد کانکشن‌ها و موارد administrator  میتونیم ماژول را  status_module فعال نمایید


       vim httpd.conf

      <Location "/server-status">
          SetHandler server-status
          Require host example.com
      </Location>

      سپس به آی پی رفته و در ادامه عبارت server-status را تایپ نمایید


      127.0.0.1/server-status


      DNS

      Resolve:

      systemd-resolve -t MX gmail.com   #show mail server

      systemd-resolve -t SOA gmail.com   #show SOA .     Start Of Authority (More administrative information)   

      URL

      systemd-resolve 85.214.157.7        #Get domain name

      nslookup domain.ir [#Finding The IP Address of an Host from default dns server]

      nslookup domain.ir 8.8.8.8[#Finding The IP Address of an Host From non default dns server]

      nslookup -querytype=mx domain.ir[ #Find Mail Servers for a Domain]

      nslookup -query=mx domain.ir [#Find Mail Servers]

      nslookup -query=ns domain.ir [ #Find NameServers]

      nslookup -query=soa domain.ir [ #display the SOA record (information about the domain]

      nslookup -query=any domain.ir [ #display all the available DNS records]



      DNS Command:

      systemd-resolve --statistics          #informations


      Flush the DNS Cache   

      URL


      Method 1: Using systemd-resolve to flush DNS-Cache

      sudo systemd-resolve --flush-caches

      sudo systemd-resolve --statistics


      Method 2: Using dns-clean to flush DNS-Cache

      sudo /etc/init.d/dns-clean start





      Options:

      update
      Retrieve new lists of packages
      upgrade:
      Perform an upgrade
      install
      Install new packages (pkg is libc6 not libc6.deb)
      remove:
      Remove packages
      purge:
      Remove packages and config files
      autoremove:
      Remove automatically all unused packages that were automatically installed to satisfy dependencies for other packages and are now no longer needed.
      dist-upgrade:
      Distribution upgrade
      build-dep:
      Configure build-dependencies for source packages. install all dependencies for 'packagename'
      clean:
      Erase downloaded archive files. clean clears out the local repository of retrieved package files. It removes everything but the lock file from /var/cache/apt/archives/ and /var/cache/apt/archives/partial/.
      autoclean:
      Erase old downloaded archive files
      check:
      Verify that there are no broken dependencies
      source:
      Download source archives. Source packages are tracked separately from binary packages via deb-src lines in the sources.list.
      [--compile]: package will be compiled to a binary .deb using dpkg-buildpackage for the architecture as defined by the [--host-architecture] option.
      [--download-only]:source package will not be unpacked.
      download:
      Download the binary package into the current directory
      changelog:
      Download and display the changelog for the given package
      سیاهه یا تاریخچهٔ تغییراتی که در پروژه صورت گرفته است
      indextargets:
      listing of information about all data files (index targets) apt-get update would download


      Options:

      [--no-install-recommends]
      در هنگام نصب، بسته‌های توصیه‌شده بعنوان وابستگی لحاظ نشوند
      [--install-suggests]
      درهنگام نصب بسته‌های پیشنهاد شونده(توسط برنامه) بعنوان وابستگی لحاظ نشوند
      [-d, --download-only]
      فقط فایل‌های بسته دانلود شوند(unpacked یا نصب نشوند)
      [-f, --fix-broken]
      تلاش برای اصلاح گسیختگی‌های موجود در  وابستگی‌ها
      با این گزینه به برنامه apt اجازه داده می‌شود تا درصورت نیاز هر بسته‌ای را حذف نماید
      [-m, --ignore-missing, --fix-missing]
      Ignore missing packages; if packages cannot be retrieved or fail the integrity check after retrieval (corrupted package files), hold back those packages and handle the result. Use of this option together with -f may produce an error in some situations. If a package is selected for installation (particularly if it is mentioned on the command line) and it could not be downloaded then it will be silently held back.
      [--no-download]
      Disables downloading of packages. This is best used with --ignore-missing to force APT to use only the .debs it has already downloaded.
      [-q, --quiet]
      Quiet; produces output suitable for logging, omitting progress indicators. More q's will produce more quiet up to a maximum of 2. You can also use -q=# to set the quiet level, overriding the configuration file. Note that quiet level 2 implies -y; you should never use -qq without a no-action modifier such as -d, --print-uris or -s as APT may decide to do something you did not expect.
      [-s, --simulate, --just-print, --dry-run, --recon, --no-act]
      No action; perform a simulation of events that would occur based on the current system state but do not actually change the system. Locking will be disabled (Debug::NoLocking) so the system state could change while apt-get is running. Simulations can also be executed by non-root users which might not have read access to all apt configuration distorting the simulation. A notice expressing this warning is also shown by default for non-root users (APT::Get::Show-User-Simulation-Note).

      Simulated runs print out a series of lines, each representing a dpkg operation: configure (Conf), remove (Remv) or unpack (Inst). Square brackets indicate broken packages, and empty square brackets indicate breaks that are of no consequence (rare).
      [-y, --yes, --assume-yes]
      Automatic yes to prompts; assume "yes" as answer to all prompts and run non-interactively. If an undesirable situation, such as changing a held package, trying to install a unauthenticated package or removing an essential package occurs then apt-get will abort.
      [--assume-no]
      Automatic "no" to all prompts.
      [--no-show-upgraded]
      Do not show a list of all packages that are to be upgraded.
      [-V, --verbose-versions]
      Show full versions for upgraded and installed packages.
      [-a, --host-architecture]
      This option controls the architecture packages are built for by apt-get source --compile and how cross-builddependencies are satisfied. By default is it not set which means that the host architecture is the same as the build architecture (which is defined by APT::Architecture).
      This option controls the activated build profiles for which a source package is built by apt-get source --compile and how build dependencies are satisfied. By default no build profile is active. More than one build profile can be activated at a time by concatenating them with a comma. 
      [-b, --compile, --build]
      Compile source packages after downloading them.
      [--ignore-hold]
      Ignore package holds; this causes apt-get to ignore a hold placed on a package. This may be useful in conjunction with dist-upgrade to override a large number of undesired holds. 
      [--with-new-pkgs]
      Allow installing new packages when used in conjunction with upgrade. This is useful if the update of a installed package requires new dependencies to be installed. Instead of holding the package back upgrade will upgrade the package and install the new dependencies. Note that upgrade with this option will never remove packages, only allow adding new ones.
      [--no-upgrade]
      Do not upgrade packages; when used in conjunction with install, no-upgrade will prevent packages on the command line from being upgraded if they are already installed.
      [--only-upgrade]
      Do not install new packages; when used in conjunction with install, only-upgrade will install upgrades for already installed packages only and ignore requests to install new packages.
      [--allow-downgrades]
      This is a dangerous option that will cause apt to continue without prompting if it is doing downgrades. It should not be used except in very special situations. Using it can potentially destroy your system!
      [--allow-remove-essential]
      Force yes; this is a dangerous option that will cause apt to continue without prompting if it is removing essentials. It should not be used except in very special situations. Using it can potentially destroy your system! 
      [--allow-change-held-packages]
      Force yes; this is a dangerous option that will cause apt to continue without prompting if it is changing held packages. It should not be used except in very special situations. Using it can potentially destroy your system! 
      [--force-yes]
      Force yes; this is a dangerous option that will cause apt to continue without prompting if it is doing something potentially harmful. It should not be used except in very special situations. Using force-yes can potentially destroy your system!. This is deprecated and replaced by --allow-downgrades, --allow-remove-essential, --allow-change-held-packages in 1.1.
      [--print-uris]
      Instead of fetching the files to install their URIs are printed. Each URI will have the path, the destination file name, the size and the expected MD5 hash. Note that the file name to write to will not always match the file name on the remote site! This also works with the source and update commands. When used with the update command the MD5 and size are not included, and it is up to the user to decompress any compressed files. 
      [--purge]
      Use purge instead of remove for anything that would be removed. An asterisk ("*") will be displayed next to packages which are scheduled to be purged.  remove --purge is equivalent to the purge command. 
      [--reinstall]
      Re-install packages that are already installed and at the newest version
      [--list-cleanup]
      This option is on by default; use --no-list-cleanup to turn it off. When it is on, apt-get will automatically manage the contents of /var/lib/apt/lists to ensure that obsolete files are erased. The only reason to turn it off is if you frequently change your sources list.
      [-t, --target-release, --default-release]
      This option controls the default input to the policy engine; it creates a default pin at priority 990 using the specified release string. This overrides the general settings in /etc/apt/preferences. Specifically pinned packages are not affected by the value of this option. In short, this option lets you have simple control over which distribution packages will be retrieved from. Some common examples might be -t '2.1*', -t unstable or -t sid. 
      [--trivial-only]
      Only perform operations that are 'trivial'. Logically this can be considered related to --assume-yes; where --assume-yes will answer yes to any prompt, --trivial-only will answer no.
      [--no-remove]
      If any packages are to be removed apt-get immediately aborts without prompting.
      [--auto-remove, --autoremove]
      If the command is either install or remove, then this option acts like running the autoremove command, removing unused dependency packages.
      [--only-source]
      Only has meaning for the source and build-dep commands. Indicates that the given source names are not to be mapped through the binary table. This means that if this option is specified, these commands will only accept source package names as arguments, rather than accepting binary package names and looking up the corresponding source package. 
      [--diff-only, --dsc-only, --tar-only]
      Download only the diff, dsc, or tar file of a source archive.
      [--arch-only]
      Only process architecture-dependent build-dependencies.
      [--indep-only]
      Only process architecture-independent build-dependencies
      [--allow-unauthenticated]
      Ignore if packages can't be authenticated and don't prompt about it. This can be useful while working with local repositories, but is a huge security risk if data authenticity isn't ensured in another way by the user itself. The usage of the Trusted option for sources.list(5) entries should usually be preferred over this global override.
      [--no-allow-insecure-repositories]
      Forbid the update command to acquire unverifiable data from configured sources. APT will fail at the update command for repositories without valid cryptographically signatures. See also apt-secure(8) for details on the concept and the implications.
      [--show-progress]
      Show user friendly progress information in the terminal window when packages are installed, upgraded or removed. For a machine parsable version of this data see README.progress-reporting in the apt doc directory. 
      [--with-source filename]
      Adds the given file as a source for metadata. Can be repeated to add multiple files. See --with-source description in apt-cache(8) for further details.
      [-c, --config-file]
      Configuration File; Specify a configuration file to use. The program will read the default configuration file and then this configuration file. If configuration settings need to be set before the default configuration files are parsed specify a file with the APT_CONFIG environment variable. See apt.conf(5) for syntax information.
      [-o, --option]
      Set a Configuration Option; This will set an arbitrary configuration option. The syntax is -o Foo::Bar=bar.  -o and --option can be used multiple times to set different options.




      FILES

      /etc/apt/sources.list:
      Locations to fetch packages from. Configuration Item: Dir::Etc::SourceList.
      /etc/apt/sources.list.d/:
      File fragments for locations to fetch packages from. Configuration Item: Dir::Etc::SourceParts.
      /etc/apt/apt.conf:
      APT configuration file. Configuration Item: Dir::Etc::Main.
      /etc/apt/apt.conf.d/:
      APT configuration file fragments. Configuration Item: Dir::Etc::Parts.
      /etc/apt/preferences:
      Version preferences file. This is where you would specify "pinning", i.e. a preference to get certain packages from a separate source or from a different version of a distribution. Configuration Item:[Dir::Etc::Preferences].
      /etc/apt/preferences.d/:
      File fragments for the version preferences. Configuration Item: Dir::Etc::PreferencesParts.
      /var/cache/apt/archives/:
      Storage area for retrieved package files. Configuration Item: Dir::Cache::Archives.
      /var/cache/apt/archives/partial/:
      Storage area for package files in transit. Configuration Item: Dir::Cache::Archives (partial will be implicitly appended)
      /var/lib/apt/lists/:
      Storage area for state information for each package resource specified in sources.list(5) Configuration Item: Dir::State::Lists.
      /var/lib/apt/lists/partial/:
      Storage area for state information in transit. Configuration Item: Dir::State::Lists (partial will be implicitly appended)

      apt

      apt command:

      list:

      [--installed], [--upgradeable], [--all-versions]

      list packages based on package names.list is somewhat similar to dpkg-query --list in that it can display a list of packages satisfying certain criteria. 

      search:

      search in package descriptions

      show:

      show package details and information about the given package(s) including its dependencies, installation and download size, sources the package is available from, the description of the packages content and such more install, remove, purge: Performs the requested action on one or more packages specified via regex(7), glob(7) or exact match. The requested action can be overridden for specific packages by append a plus (+) to the package name to install this package or a minus (-) to remove it.

      autoremove:

      Remove automatically all unused packages that were automatically installed to satisfy dependencies for other packages and are now no longer needed as dependencies changed

      update:

      update list of available packages

      upgrade:

      upgrade the system by installing/upgrading packages

      full-upgrade:

      upgrade the system by removing/installing/upgrading packages

      edit-sources:

      edit the source information file (edit your sources.list)



      CLOSED: #Indicates that the server has received an ACK signal from the client and the connection is closed

      CLOSE_WAIT: #[Indicates that the server has received the first FIN signal from the client and the connection is in the process of being closed]

      #[So this essentially means that his is a state where socket is waiting for the application to execute close()]

      #[A socket can be in CLOSE_WAIT state indefinitely until the application closes it]

      #[Faulty scenarios would be like filedescriptor leak, server not being execute close() on socket leading to pile up of close_wait sockets]

      ESTABLISHED: #Indicates that the server received the SYN signal from the client and the session is established

      FIN_WAIT_1: #Indicates that the connection is still active but not currently being used

      FIN_WAIT_2: #Indicates that the client just received acknowledgment of the first FIN signal from the server

      LAST_ACK #Indicates that the server is in the process of sending its own FIN signal

      LISTENING: #Indicates that the server is ready to accept a connection

      SYN_RECEIVED: #Indicates that the server just received a SYN signal from the client

      SYN_SEND: #Indicates that this particular connection is open and active

      TIME_WAIT: #Indicates that the client recognizes the connection as still active but not currently being used


      def tor_request(url, jsn=None, method="get"):
         session = requests.session()
         session.proxies = {'http': 'socks5h://localhost:9050', 'https': 'socks5h://localhost:9050'}
         resp = None
         if method == "get":
         resp = session.get(url=url, json=jsn)
         elif method == "post":
         resp = session.post(url=url, json=jsn)
         del session
         return resp.json()

      اگر بخواهیم هر شش ثانبه کد ما آی پی جدید به خود اتخاذ نماید باید از دستور زیر استفاده نماییم:

      $ vim /etc/tor/torrc
      
      #Append to end
      .
      .
      .
      MaxCircuitDirtiness 1
      

       

       

       


      Options:

      update
      گرفتن (دوباره بدست آوردن) لیست بسته‌های جدید
      upgrade:
      آپگرید کردن
      install
      نصب یک بسته
      remove:
      حذف یک بسته
      purge:
      حذف بسته به همراه تمامی تنظیمات آن
      autoremove:
      Remove automatically all unused packages that were automatically installed to satisfy dependencies for other packages and are now no longer needed.
      dist-upgrade:
      Distribution upgrade
      build-dep:
      Configure build-dependencies for source packages. install all dependencies for 'packagename'
      clean:
      Erase downloaded archive files. clean clears out the local repository of retrieved package files. It removes everything but the lock file from /var/cache/apt/archives/ and /var/cache/apt/archives/partial/.
      autoclean:
      پاک کردن فایل‌های آرشیو شده از دانلود‌های قبلی
      check:
      Verify that there are no broken dependencies
      source:
      Download source archives. Source packages are tracked separately from binary packages via deb-src lines in the sources.list.
      [--compile]: package will be compiled to a binary .deb using dpkg-buildpackage for the architecture as defined by the [--host-architecture] option.
      [--download-only]:source package will not be unpacked.
      download:
      دانلود فایل باینری در مسیر فعلی
      changelog:
      Download and display the changelog for the given package
      سیاهه یا تاریخچهٔ تغییراتی که در پروژه صورت گرفته است
      indextargets:
      listing of information about all data files (index targets) apt-get update would download


      Options:

      [--no-install-recommends]
      در هنگام نصب، بسته‌های توصیه‌شده بعنوان وابستگی لحاظ نشوند
      [--install-suggests]
      درهنگام نصب بسته‌های پیشنهاد شونده(توسط برنامه) بعنوان وابستگی لحاظ نشوند
      [-d, --download-only]
      فقط فایل‌ها دانلود شوند(unpacked یا نصب نشوند)
      [-f, --fix-broken]
      تلاش برای اصلاح گسیختگی‌های موجود در  وابستگی‌ها
      با این گزینه به برنامه apt اجازه داده می‌شود تا درصورت نیاز هر بسته‌ای را حذف نماید
      [-m, --ignore-missing, --fix-missing]
      نادیده گرفتن بسته‌‌های‌ خرابی(مثلا دانلود نمیشوند یا اینکه دانلود شده اند ولی خراب هستند)
      اگر بسته‌ها نمی‌توانند دانلود شوند یا بعد از دانلود امکان چک و بررسی یکپارچکی وجود نداردآن بسته‌ها را عقب نگه‌دار و نتیجه را هندل کن
      اگر این سوییچ را با -f استفاده نمایید ممکن است در  مواردی به ارور برخورد نمایید
      اگر نام یک بسته در خط فرمان برای نصب آورده شده باشد درصورت عدم دانلود این بسته بدون هیچ گونه اخطاری از نصب این بسته صرف نظر میشود
      [--no-download]
      فقط از بسته‌های deb موجود(کنونی) در سیستم‌عامل که پیش‌تر دانلود شده استفاده شود
      [-q, --quiet]
      این کامند برای تهیه لاگ بسیار مفید است زیرا نشانگرهای پیشرفت و موارد توضیحاتی را حذف می‌کند
      با مقداردهی به -q=# میتوانیم  سطح عدم تولید توضیحات را مشخص نماییم
      [-s, --simulate, --just-print, --dry-run, --recon, --no-act]
      هیچ کاری صورت نگیرد
      شبیه‌سازی و نمایش در خروجی از تغییراتی که با اجرای دستور صورت خواهد گرفت
      [-y, --yes, --assume-yes]
      بطور اتوماتیک به هر  prompt پاسخ yes خواهد داد
      run non-interactively
      در موارد نامطلوب دستور apt-get متوقف خواهد شد(نظیر: تغییر در نگهداری بسته یا نصب یک بسته غیرمجاز  یا حذف یک بسته خیلی مهم)
      [--assume-no]
      بصورت پیش‌فرض به  همه promp ها پاسخ no می‌دهد
      [--no-show-upgraded]
      عدم نمایش لیست تمام بسته‌هایی که آپگرید شده‌اند
      [-V, --verbose-versions]
      نمایش نسخه تمام نسخه‌ها از بسته‌هایی که آپگرید شده‌اند
      [-a, --host-architecture]
      بصورت پیش‌فرض تنظیم نیست
      در زمان استفاده از دستور apt-get source --compile معماری بسته‌های build شونده کنترل و  cross-builddependencies تامین شوند
      [-b, --compile, --build]
      Compile source packages after downloading them.
      [--ignore-hold]
      Ignore package holds;
      بسته را نگهداری ننماید-به عبارتی پس از نصب آن را در سیستم نگه‌ندارد
      [--with-new-pkgs]
      این سوییچ وقتی با دستور upgrade همراه شود دراین صورت مجاز به نصب بسته‌های جدید خواهد بود.
      این دستور زمان نیازمندی به یک dependency مفید خواهد بود تا آن نیز بتواند نصب نماید
      نکته:دستور upgrade هیچگاه بسته‌ای را حذف نمی‌کند و فقط بسته جدید را نصب می‌کند
      [--no-upgrade]
      Do not upgrade packages;
      همراه با دستور  install : اگر بسته هم‌اکنون نصب شده باشد آنگاه از  upgrade آن دستور جلوگیری بعمل خواهد آمد
      [--only-upgrade]
      همراه با دستور  install : اگر بسته هم‌اکنون در سیستم‌عامل موجود نباشد، نصب صورت نگیرد
      تنها زمانی بسته را آپگرید خواهد کرد که درحال حاضر بسته در سیستم‌عامل وجود داشته و ورژن جدید از آن در دسترس باشد
      [--allow-downgrades]
      این دستور خطرناک است و ممکن است به سیستم عامل آسیب برساند
      تنها در موارد خاص کاربرد دارد و در صورت دانلود ممکن است پیغامی ظاهر نشود
      [--allow-remove-essential]
      این دستور خطرناک است و ممکن است به سیستم عامل آسیب برساند
      بله(Force yes) به حذف دستوراتی که بعنوان پایه در سیستم عامل کاربرد دارند
      [--force-yes]
      بله(Force yes) به تمامی پیغام‌ها
      این دستور منقرض شده است و با دستورات
        --allow-downgrades, --allow-remove-essential, --allow-change-held-packages 
      جایگزین شده است
      [--print-uris]
      بجای اینکه فایل‌ها نصب شوند آدرس URL آن پرینت می‌شود
      هر URL دارای path و destination file name و سایز و کد MD5 است
      sudo apt-get install aptitude --print-uris
      [sudo] password for behrooz: 
      Reading package lists. Done
      Building dependency tree       
      Reading state information. Done
      The following additional packages will be installed:
        aptitude-common libclass-accessor-perl libcwidget3v5 libio-string-perl libparse-debianchangelog-perl libsub-name-perl
      Suggested packages:
        aptitude-doc-en | aptitude-doc apt-xapian-index debtags libcwidget-dev libhtml-template-perl libxml-simple-perl
      The following NEW packages will be installed:
        aptitude aptitude-common libclass-accessor-perl libcwidget3v5 libio-string-perl libparse-debianchangelog-perl libsub-name-perl
      0 upgraded, 7 newly installed, 0 to remove and 38 not upgraded.
      Need to get 3,494 kB of archives.
      After this operation, 15.8 MB of additional disk space will be used.
      'http://deb.debian.org/debian/pool/main/a/aptitude/aptitude-common_0.8.7-1_all.deb' aptitude-common_0.8.7-1_all.deb 1592678 MD5Sum:944f23494615284543660e9ee02c6c6d
      'http://deb.debian.org/debian/pool/main/c/cwidget/libcwidget3v5_0.5.17-4+b1_amd64.deb' libcwidget3v5_0.5.17-4+b1_amd64.deb 312582 MD5Sum:153078784a4cac12829bfb967cd9b8c4
      'http://deb.debian.org/debian/pool/main/a/aptitude/aptitude_0.8.7-1_amd64.deb' aptitude_0.8.7-1_amd64.deb 1477860 MD5Sum:3bd5df11a809e76d0e925e705b0f9f06
      'http://deb.debian.org/debian/pool/main/libs/libsub-name-perl/libsub-name-perl_0.21-1_amd64.deb' libsub-name-perl_0.21-1_amd64.deb 13122 MD5Sum:d2ae0127b9770f1511f9d8d6e65c415a
      'http://deb.debian.org/debian/pool/main/libc/libclass-accessor-perl/libclass-accessor-perl_0.34-1_all.deb' libclass-accessor-perl_0.34-1_all.deb 25950 MD5Sum:e8d44fcd57dcb4a39e53f7956b30dd22
      'http://deb.debian.org/debian/pool/main/libi/libio-string-perl/libio-string-perl_1.08-3_all.deb' libio-string-perl_1.08-3_all.deb 12298 MD5Sum:8d09424a4c3ba34a8ff890af95391947
      'http://deb.debian.org/debian/pool/main/libp/libparse-debianchangelog-perl/libparse-debianchangelog-perl_1.2.0-12_all.deb' libparse-debianchangelog-perl_1.2.0-12_all.deb 59376 MD5Sum:52a19d38904388812afef8d78611e26e
      

      [--purge]
      اگر بجای remove استفاده شود در این صورت همه چیز را پاک خواهد کرد
      [--reinstall]
      نصب مجدد بسته‌های که هم‌اکنون نصب شده است(در ورژن بالاتر)
      [--list-cleanup]
      بطور پیش‌فرض این سوییچ در دستور تعبیه شده است
      درصورت روشن بودن دستور apt  بطور اتوماتیک محتوی /var/lib/apt/lists  مدیریت را مدیریت کرده و اطمینان حاصل می‌گردد که فایل‌های منسوخ پاک شده باشد
      تنها دلیلی که این ویژگی را می‌توان خاموش کرد این استکه این فایل بطور مداوم تغییر می‌نماید
      نکته: از سوییچ  --no-list-cleanup برای خاموش کردن آن استفاده می‌شود
      [--no-remove]
      اگر هر بسته‌ای بخواهد حذف شود دستور apt-get همان موقع بدون اینکه pronpt بدهد قطع می‌شود
      [--auto-remove, --autoremove]
      Remove automatically all unused packages that were automatically installed to satisfy dependencies for other packages and are now no longer needed as dependencies changed
      [--only-source]
      تنها در دستورات buil-dep و  source معنی پیدا می‌کند.
      نشان میدهد که نام سورس داده شده به فایل‌های باینری مپ نشده باشد و دستورات تنها  نام بسته‌های سورس را بعنوان آرگومان قبول نمایند
      [--allow-unauthenticated]
      Ignore if packages can't be authenticated and don't prompt about it.
      This can be useful while working with local repositories, but is a huge security risk if data authenticity isn't ensured in another way by the user itself.
      The usage of the Trusted option for sources.list(5) entries should usually be preferred over this global override.
      [--no-allow-insecure-repositories]
      در دستور update ، از گرفتن دیتا‌ی verified نشده جلوگیری بعمل می‌آورد
      دستور apt update در صورت مواجهه با  ریپوزیتوری‌هایی با امضای رمز شده غیر معتبر ، fail می‌شود
      [--show-progress]
      نمایش نوار میزان پیشرفت کار در حین نصب با پاک یا آپگرید
      [--with-source filename]
      Adds the given file as a source for metadata. Can be repeated to add multiple files. See --with-source description in apt-cache(8) for further details.
      [-c, --config-file]
      Specify a configuration file to use.
      The program will read the default configuration file and then this configuration file.
      If configuration settings need to be set before the default configuration files are parsed specify a file with the APT_CONFIG environment variable. See apt.conf(5) for syntax information.



      FILES

      /etc/apt/sources.list:
      Locations to fetch packages from. Configuration Item: Dir::Etc::SourceList.
      /etc/apt/sources.list.d/:
      File fragments for locations to fetch packages from. Configuration Item: Dir::Etc::SourceParts.
      /etc/apt/apt.conf:
      APT configuration file. Configuration Item: Dir::Etc::Main.
      /etc/apt/apt.conf.d/:
      APT configuration file fragments. Configuration Item: Dir::Etc::Parts.
      /etc/apt/preferences:
      Version preferences file. This is where you would specify "pinning", i.e. a preference to get certain packages from a separate source or from a different version of a distribution. Configuration Item:[Dir::Etc::Preferences].
      /etc/apt/preferences.d/:
      File fragments for the version preferences. Configuration Item: Dir::Etc::PreferencesParts.
      /var/cache/apt/archives/:
      Storage area for retrieved package files. Configuration Item: Dir::Cache::Archives.
      /var/cache/apt/archives/partial/:
      Storage area for package files in transit. Configuration Item: Dir::Cache::Archives (partial will be implicitly appended)
      /var/lib/apt/lists/:
      Storage area for state information for each package resource specified in sources.list(5) Configuration Item: Dir::State::Lists.
      /var/lib/apt/lists/partial/:
      Storage area for state information in transit. Configuration Item: Dir::State::Lists (partial will be implicitly appended)

      apt

      apt command:

      list:

      [--installed], [--upgradeable], [--all-versions]

      list packages based on package names.list is somewhat similar to dpkg-query --list in that it can display a list of packages satisfying certain criteria. 

      search:

      search in package descriptions

      show:

      show package details and information about the given package(s) including its dependencies, installation and download size, sources the package is available from, the description of the packages content and such more install, remove, purge: Performs the requested action on one or more packages specified via regex(7), glob(7) or exact match. The requested action can be overridden for specific packages by append a plus (+) to the package name to install this package or a minus (-) to remove it.

      autoremove:

      Remove automatically all unused packages that were automatically installed to satisfy dependencies for other packages and are now no longer needed as dependencies changed

      update:

      update list of available packages

      upgrade:

      upgrade the system by installing/upgrading packages

      full-upgrade:

      upgrade the system by removing/installing/upgrading packages

      edit-sources:

      edit the source information file (edit your sources.list)




      Options
      [-y]: Assume that the answer to simple yes/no questions is 'yes' 
      [-v]: Display extra information. (may be supplied multiple times)

      Matcher Selection

      [-f FILE, --file=FILE]

      الگو‌ها را از فابل بخواند. هر الگو در یک خط نوشته شود

      The empty file contains zero patterns, and therefore matches nothing.

      [-i, --ignore-case, -y]

      عدم حساسیت به حروف بزرگ و کوچک

      Ignore case distinctions in both the PATTERN and the input files.

      y  سوییچ قدیمی هست و i جدیدتری است

      [-v, --invert-match]

      الگوی مورد نظر را نشان ندهد

      [-w, --word-regexp]
      Select  only those lines containing matches that form whole words.
      $ grep -w ping  #does not match ping”
      [-x, --line-regexp]

      درصورتی چیزی پیدا کن که (دقیقا) تمام یک خط  دقیق الگوی وارد شده باشد

      $ grep "hello I am behrooz"
       sample3:hello I am behrooz
       sample3:hello I am behrooz! and what is this
       sample3:hello I am behrooz!, I am fine
      $ grep -x "hello I am behrooz"
       sample3:hello I am behrooz


      General Output Control

      [-c, --count]
      Count the Number of Matches
      $ grep -c salam *.txt
      sample1.txt:7
      sample2.txt:1
      sample3.txt:31
      sample4.txt:22
      --color[=WHEN], --colour[=WHEN]
      export GREP_COLOR='1;32'    #setting green color for pattern
      cat file.txt |grep PATTERN --color=auto
      [-L, --files-without-match]
      فایل‌هایی که الگو را دارا نمی‌باشند
      $ grep -L "how" *.txt     #find all files (in the current directory) that do not contain the word "how"
      file1.txt
      file25.txt
      file67.txt
      [-l, --files-with-matches]
      تنها نام فایل‌هایی که الگو در آن یافت شده است را نشان خواهد داد
      $ grep -l "how" *.txt     #find all files (in the current directory) that do not contain the word "how"
      file1.txt
      file25.txt
      file67.txt
       [-m NUM, --max-count=NUM]
      Stop  reading a file after NUM matching lines.  If the input is standard input from a regular file, and NUM matching lines are output, grep ensures that the standard input is positioned to just after the last matching line before exiting, regardless
                    of the presence of trailing context lines.
      This enables a calling process to resume a search.  When grep stops after NUM matching lines, it outputs any trailing context lines.  When the -c or --count option is also used,  grep  does  not  output  a
                    count greater than NUM.
      When the -v or --invert-match option is also used, grep stops after outputting NUM non-matching lines.

      [-o, --only-matching]
      Print only the matched (non-empty) parts of a matching line, with each such part on a separate output line.

      [-q, --quiet, --silent]
      Quiet; do not write anything to standard output.  Exit immediately with zero status if any match is found, even if an error was detected.  Also see the -s or --no-messages option.
      [-s, --no-messages]
                    Suppress error messages about nonexistent or unreadable files.


      ${parameter:=word}:

      If parameter is unset or null, the expansion of word is assigned to parameter.
      The value of parameter is then substituted. 
      Positional parameters and special parameters may not be assigned to in this way.

      ${var:-value}: 

      if ${var} is set and not null, or value otherwise.
      The ${var-value} construct is similar, but checks only that the variable is set.

      ${var:=value} and ${var=value}:

      if var is unset (and also set, but null for the := form).

      ${var:?message}:

      display message to stderr and then exit if var is unset or null.
      This should generally not be used within ebuilds as it does not use the die mechanism.
      There is a ${var?message} form too.

      ${var:+value}:

      if var is set and not null, or a blank string otherwise.
      There is a ${var+value} form.

       

       

      URL


      ps

      ps

       دستور پی اس بدون سوییچ فقط پروسس های ترمینال کنونی را نمایش خواهد داد

      سوییچ l (ال) : توضیحاتی اضافه از پروسس های ترمینال کنونی  

      پارامترهای F: 1: پردازش در حافظه در حال اجرا است

      2: معرف یک systemProcess استفاده

      3: پردازش در حافظه lock شده است بخاطر عملیات IO

      4: پردازش در وضعیت SWAP است

      پارامترهای:‌S

      کاراکتر W: پردازش در حال انتظار است

      کاراکتر R:  پردازش در حال اجرا

      کاراکتر S:  پردازش در  حال sleep

      کاراکتر Z: اجرای پروسس به اتمام رسیده است

      کاراکتر T:  پروسس متوقف شده است

      پارامتر PPID: پردازه پدر این پردازه - چه پروسسی این پردازه را به اجرا در آورده است


      ps -el

      نمایش تمام پردازه های فعال و درحال اجرا 

      با قرار دادن nohup باعث می‌شویم که با logOff هم دستور از بین نرود



      !! 

      execute last command.

      !top

      execute the most recent command that starts with ‘top’ (e.g. !).

      !top:p

      displays the command that !top would run (also adds it as the latest command in the command history).

      !$ 

      execute the last word of the previous command (same as Alt +., e.g. if last command is ‘cat tecmint.txt’, then !$ would try to run ‘tecmint.txt’).

      !$:p

      displays the word that !$ would execute.

      !*

      displays the last word of the previous command.

      !*:p

      displays the last word that !* would substitute.



      tcpdump -i eth0 #Capture Packets from Specific Interface

      tcpdump -i any #Capture all packets in any interface

      tcpdump -c 5 -i eth0 #Capture Only N Number of Packets

      tcpdump -A -i eth0 #Print Captured Packets in ASCII

      tcpdump -D #Display Available Interfaces

      tcpdump -XX -i eth0 #Display Captured Packets in HEX and 

      tcpdump -w 0001.pcap -i eth0 #Capture and Save Packets in a File

      tcpdump -r 0001.pcap #Read Captured Packets File

      tcpdump -n #show IP address replace name (disable name resolution) 

      tcpdump -nn  #show port address replace name (disable port resolution with -nn

      tcpdump  tcp #Capture only TCP Packets.

      tcpdump port 22 #Capture Packet from Specific Port

      tcpdump port 80 #capture packets related to a web (HTTP) service

      tcpdump -i eth0 src 192.168.0.2 #Capture Packets from source IP

      tcpdump -i eth0 dst 50.116.66.139 #Capture Packets from destination IP

      tcpdump --number #show acket numbers in output

      tcpdump -t #omit timestamp info from tcpdump outpu

      tcpdump -v #show detailed output

      tcpdump  icmp #capture ICMP packets only

      tcpdump host 54.204.39.132 #only packets related to a specific host

      tcpdump -i any -c5 -nn \

           src 192.168.122.98 and port 80 #filter packets from source IP address 192.168.122.98 and service HTTP only

      tcpdump -i any -c5 -nn "port 80 \

           and (src 192.168.122.98 \

           or src 54.204.39.132)" #filtering packets for HTTP service only (port 80) and source IP addresses 192.168.122.98 or 54.204.39.132



      URL


      Matcher Selection

      [-f FILE, --file=FILE]

      الگو‌ها را از فابل بخواند. هر الگو در یک خط نوشته شود

      The empty file contains zero patterns, and therefore matches nothing.

      [-i, --ignore-case, -y]

      عدم حساسیت به حروف بزرگ و کوچک

      Ignore case distinctions in both the PATTERN and the input files.

      y  سوییچ قدیمی هست و i جدیدتری است

      [-v, --invert-match]

      الگوی مورد نظر را نشان ندهد

      [-w, --word-regexp]
      Select  only those lines containing matches that form whole words.
      $ grep -w ping  #does not match ping”
      [-x, --line-regexp]

      درصورتی چیزی پیدا کن که (دقیقا) تمام یک خط  دقیق الگوی وارد شده باشد

      $ grep "hello I am behrooz"
       sample3:hello I am behrooz
       sample3:hello I am behrooz! and what is this
       sample3:hello I am behrooz!, I am fine
      $ grep -x "hello I am behrooz"
       sample3:hello I am behrooz


      General Output Control

      [-c, --count]
      Count the Number of Matches
      $ grep -c salam *.txt
      sample1.txt:7
      sample2.txt:1
      sample3.txt:31
      sample4.txt:22
      --color[=WHEN], --colour[=WHEN]
      export GREP_COLOR='1;32'    #setting green color for pattern
      cat file.txt |grep PATTERN --color=auto
      [-L, --files-without-match]
      فایل‌هایی که الگو را دارا نمی‌باشند
      $ grep -L "how" *.txt     #find all files (in the current directory) that do not contain the word "how"
      file1.txt
      file25.txt
      file67.txt
      [-l, --files-with-matches]
      تنها نام فایل‌هایی که الگو در آن یافت شده است را نشان خواهد داد
      $ grep -l "how" *.txt     #find all files (in the current directory) that do not contain the word "how"
      file1.txt
      file25.txt
      file67.txt
       [-m NUM, --max-count=NUM]
      توقف بعد از اینکه تعداد مشخص شده پیدا شده باشد
      [-q, --quiet, --silent]
      Quiet; do not write anything to standard output
      Exit immediately with zero status if any match is found, even if an error was detected.
      [-s, --no-messages]
                    Suppress error messages about nonexistent or unreadable files.


      option:

      -i This installs a new package(rpm -i package)

      -F This will upgrade packages, but only if an earlier version currently exists(rpm -F package)

      -U This upgrades or installs the package currently installed to a newer version(rpm -U package)

      -e erase (uninstall) package(rpm -e package)

      -q query packages(rpm -q package)

      -V verify installed packages(rpm -V package)

      -K verify package signature(rpm -K package)

      --rebuilddb rebuild the database indices from the installed package headers(rpm --rebuilddb)

      --initdb create a new database if one doesn’t already exist(rpm --initdb)

      --import import PUBKEY(rpm --import /usr/share/rhn/RPM-GPG-KEY)


      options with i, U:

      -v show package name(rpm -iv package)

      -h display progress(rpm -ivh package)

      -vv Print lots of ugly debugging information(rpm -ivv package)

      --nodeps Don’t do a dependency check before installing or upgrading a package(rpm -ivh --nodeps package)

      --test Don’t really uninstall anything, just go through the motions(rpm -ivh --test package)


      options with q:

      -a Query all installed packages(rpm -qa)

      -i Display package information, including name, version, and description. This uses the --queryformat if one was specified(rpm -qi) package

      -l List files in package(rpm -ql package)

      -c List only configuration files (implies -l)(rpm -qc package)

      -d List only documentation files (implies -l)(rpm -qd package)

      -f Query package owning FILE(rpm -qf /bin/bash)

      -R List packages on which this package depends(rpm -qR package)

      -s Display the states of files in the package (implies -l)(rpm -qs package)

      --last Orders the package listing by install time such that the latest packages are at the top(rpm -q --last package)

      --changelog Display change information for the package(rpm -q --changelog package)



      نمایش درصد پیشرفت کار

      rpm -i APP.rpm --percent

       برای ساخته شدن بانک اطلاعاتی RPM استفاده میشود و اینکه از این دیتابیس برای نگهداری اطلاعات مربوط به بسته های نرم افزاری نصب شده در سیستم عامل استفاده می‌شود

      rpm --rebuilddb

      جلوگیری از نصب برخی مستندات از قبیل man pages

      rpm -i APP.rpm --excludedocs

      نصب مستندات و موارد توضیحی(بصورت پیشفرض در دستور قرار دارد)

      rpm -i APP.rpm --included

      جایگزین شدن فایل‌های نرم‌افزار جدید برروی نرم افزار قدیمی(نسخه‌های قدیمی از همان نرم‌افزار)

      rpm -i APP.rpm --replacefiles

      جایگزین شدن بسته‌‌های نرم‌افزار جدید برروی نرم افزار قدیمی(نسخه‌های قدیمی از همان نرم‌افزار)

      rpm -i APP.rpm --replacepkgs

      بعد از نصب نرم‌افزار تعداد 50 کاراکتر (#) روی صفحه نمایش ظاهر شود

      rpm -i APP.rpm --hash

      بررسی نکردن وابستگی‌ها در حین پاک نمودن یک بسته

      rpm -e APP.rpm -nodeps




      rpm -e  --test -vv  APP.rpm

      دستور بصورت واقعی صورت نپذیرد و فقط مراحل اجرای دستور در صفحه نمایش نشان داده شود


      rpm -ql kernel

       فایل‌های نصب شده در سیستم عامل از برنامه مورد نظر(بهتر است بجای l از سوییچ s استفاده شود که وضعیت را هم نمایش دهد)

       rpm -qs kernel

       فایل‌هایی که در سیستم عامل به نصب بسته مورد نظر ارتباط دارد (اگر فایل خراب شده باشد عبارت missing نمایش داده خواهد شد)-(این سوییچ کمی کامل‌تر از l [ال]می‌باشد)

       

       rpm -qd kernel

       لیست شدن فایل‌های توضیحاتی از بسته مورد نظر


       توضیحات کامل از بسته

       rpm -qi kernel

       rpm -qa kernel

       فهرستی از تمام بسته های نصب شده در سیستم عامل

       


      Basic Concepts in Firewalld

      Zones: The firewalld daemon manages groups of rules using entities called zones”

      predefined zones:

      drop: The lowest level of trust. All incoming connections are dropped without reply and only outgoing connections are possible.
      block: Similar to the above, but instead of simply dropping connections, incoming requests are rejected with an icmp-host-prohibited or icmp6-adm-prohibited message.
      public: Represents public, untrusted networks. You don’t trust other computers but may allow selected incoming connections on a case-by-case basis.
      external: External networks in the event that you are using the firewall as your gateway. It is configured for NAT masquerading so that your internal network remains private but reachable.
      internal: The other side of the external zone, used for the internal portion of a gateway. The computers are fairly trustworthy and some additional services are available.
      dmz: Used for computers located in a DMZ (isolated computers that will not have access to the rest of your network). Only certain incoming connections are allowed.
      work: Used for work machines. Trust most of the computers in the network. A few more services might be allowed.
      home: A home environment. It generally implies that you trust most of the other computers and that a few more services will be accepted.
      trusted: Trust all of the machines in the network. The most open of the available options and should be used sparingly.

      Rule Permanence: In firewalld, rules can be designated as either permanent or immediate. Most firewall-cmd operations can take the "--permanent" flag

      Commands

      Install

      Install and Enable Your Firewall to Start at Boot

      $ sudoyum install firewalld  Install
      $ sudo systemctl enable firewalld
      $ sudo reboot

      Show Status(Information)

      verify the service is running and reachable by typing:

      $ sudo firewall-cmd --state
      output:  running

      Current Firewall Rules( which zone is currently selected as the default)

      firewall-cmd --get-default-zone
      output:
         publicPrint currently active zones
      

      Print currently active zones

      firewall-cmd --get-active-zones
      output:
       privateDNS
         interfaces: eth1
       publicweb
         interfaces: eth0

      list of the available zone

      $ sudo firewall-cmd --get-zones
      output:
      block dmz drop external home internal public trusted work

      see the specific configuration associated with a zone

      $ sudo firewall-cmd --zone=home --list-all
      output :
      home
        interfaces: 
        sources: 
        services: dhcpv6-client ipp-client mdns samba-client ssh
        ports: 
        masquerade: no
        forward-ports: 
        icmp-blocks: 
        rich rules:
      

      see the specific configuration associated with all zone

      sudo firewall-cmd --list-all-zones

      list of the available services

      firewall-cmd --get-services
      output
         RH-Satellite-6 amanda-client amanda-k5-client bacula bacula-client bitcoin bitcoin-rpc bitcoin-testnet bitcoin-testnet-rpc ceph ceph-mon cfengine condor-collector ctdb dhcp dhcpv6 dhcpv6-client dns docker-registry dropbox-lansync elasticsearch freeipa-ldap freeipa-ldaps freeipa-replication freeipa-trust ftp ganglia-client ganglia-master high-availability http https imap imaps ipp ipp-client ipsec iscsi-target kadmin kerberos kibana klogin kpasswd kshell ldap ldaps libvirt libvirt-tls managesieve mdns mosh mountd ms-wbt mssql mysql nfs nrpe ntp open ovirt-imageio ovirt-storageconsole ovirt-vmconsole pmcd pmproxy pmwebapi pmwebapis pop3 pop3s postgresql privoxy proxy-dhcp ptp pulseaudio puppetmaster quassel radius rpc-bind rsh rsyncd samba samba-client sane sip sips smtp smtp-submission smtps snmp snmptrap spideroak-lansync squid ssh synergy syslog syslog-tls telnet tftp tftp-client tinc tor-socks transmission-client vdsm vnc-server wbem-https xmpp-bosh xmpp-client xmpp-local xmpp-server

      list services

      sudo firewall-cmd --zone=public --list-all
      sudo firewall-cmd --zone=public --list-services

      List of ports

      sudo firewall-cmd --zone=public --list-ports

       

      Modify

      Changing the Zone of an Interface

      sudo firewall-cmd --zone=home --change-interface=eth0
      output
      success
      

      Adjusting the Default Zone

      sudo firewall-cmd --set-default-zone=home
      

      allow http/https traffic in our public” zone

      sudo firewall-cmd --zone=public --add-service=http
      sudo firewall-cmd --zone=public --add-service=http  --permanent
      sudo firewall-cmd --zone=public --add-service=https
      sudo firewall-cmd --zone=public --permanent --add-service=https
      

      Opening a Port for your Zones

      sudo firewall-cmd --zone=public --add-port=5000/tcp
      sudo firewall-cmd --zone=public --add-port=4990-4999/udp
      sudo firewall-cmd --zone=public --permanent --add-port=5000/tcp
      sudo firewall-cmd --zone=public --permanent --add-port=4990-4999/udp
      sudo firewall-cmd --zone=public --permanent --list-ports

      change interface over zones

      sudo firewall-cmd --zone=public --change-interface=eth0
      

       

      URL


      در آموزش زیر :
          آدرس شبکه :10.0.20.0/24
          نام دامنه: MyDomain.it
          سرور دی ان اس: 10.0.20.240
          سرورد دی ان اس برای فوروارد:192.168.100.12

      $ sudo apt install bind9 bind9utils dnsutils resolvconf

      $ sudo vim /etc/bind/named.conf.options

      ​​options {
          directory "/var/cache/bind";
          listen-on port 53 {localhost;10.0.20.0/24;192.168.40.0/24; };
          allow-query {localhost;10.0.20.0/24;192.168.40.0/24;};
          recursion yes;
          forwarders {
              192.168.100.12;
              8.8.8.8;
          };
          dnssec-validation auto;
          auth-nxdomain no;    # conform to RFC1035
          listen-on-v6 { any; };
      };

      $ sudo vim /etc/bind/named.conf.local

          zone "MyDomain.it" IN {
              type master;
              file "MyDomain.it";
          };

      $ vim /var/cache/bind/domain.ir

          $TTL 86400
      @    IN    SOA             ns1.MyDomain.it. root.MyDomain.it(
              20191214           ;Serial
              3600               ;Refresh
              900                ;Retry
              604800             ;Expired
              86400              ;Minimum TTL
      )
      
      ;name servers: NS records
          IN    NS       ns1.MyDomain.it.
          IN    A        192.168.40.40
          IN    MX 10    mail.MyDomain.it.
      
      ;name servers: A records
      ns1.MyDomain.it.         IN    A    192.168.40.40
      dns.MyDomain.it.         IN    A    192.168.40.40
      root.MyDomain.it.        IN    A    192.168.40.40
      MyDomain.it.             IN    A    192.168.40.40
      chat.MyDomain.it.        IN    A    192.168.40.41
      mail.MyDomain.it.        IN    A    192.168.40.42
      email.MyDomain.it.       IN    A    192.168.40.42
      pop3.MyDomain.it.        IN    A    192.168.40.42
      smtp.MyDomain.it.        IN    A    192.168.40.42
      imap.MyDomain.it.        IN    A    192.168.40.42
      behrooz.MyDomain.it.     IN    A    192.168.40.48
      • لاگ افتادن تمام کوئری‌هایی که به سرور DNS زده می‌شود(دستور زیر را در سرور وارد نمایید):
      # rndc querylog on
      • دستور زیر برای چک شدن named.conf و موارد included های آن است
      $ sudo named-checkconf
      
      • دستور زیر برای چک شدن زون‌ها می‌باشد
      # /usr/sbin/named-checkzone my.net /var/cache/bind/my.net.zone
      • در systemctl سرویس را در حالت اجرای اتوماتیک بعد از ریست قرار میدهیم
      $ sudo systemctl enable bind9
      $ sudo systemctl start  bind9
      • نکته: برای استفاده از فایل /etc/resolv.conf باید برنامه resolvconf نصب شده باشد

        URL

        URL


      Options:

      update
      گرفتن (دوباره بدست آوردن) لیست بسته‌های جدید
      upgrade:
      آپگرید کردن
      install
      نصب یک بسته
      remove:
      حذف یک بسته
      purge:
      حذف بسته به همراه تمامی تنظیمات آن
      autoremove:
      Remove automatically all unused packages that were automatically installed to satisfy dependencies for other packages and are now no longer needed.
      dist-upgrade:
      Distribution upgrade
      build-dep:
      Configure build-dependencies for source packages. install all dependencies for 'packagename'
      clean:
      Erase downloaded archive files. clean clears out the local repository of retrieved package files. It removes everything but the lock file from /var/cache/apt/archives/ and /var/cache/apt/archives/partial/.
      autoclean:
      پاک کردن فایل‌های آرشیو شده از دانلود‌های قبلی
      check:
      Verify that there are no broken dependencies
      source:
      Download source archives. Source packages are tracked separately from binary packages via deb-src lines in the sources.list.
      [--compile]: package will be compiled to a binary .deb using dpkg-buildpackage for the architecture as defined by the [--host-architecture] option.
      [--download-only]:source package will not be unpacked.
      download:
      دانلود فایل باینری در مسیر فعلی
      changelog:
      Download and display the changelog for the given package
      سیاهه یا تاریخچهٔ تغییراتی که در پروژه صورت گرفته است
      indextargets:
      listing of information about all data files (index targets) apt-get update would download
       

       


      Options:

      [--no-install-recommends]
      در هنگام نصب، بسته‌های توصیه‌شده بعنوان وابستگی لحاظ نشوند
      [--install-suggests]
      درهنگام نصب بسته‌های پیشنهاد شونده(توسط برنامه) بعنوان وابستگی لحاظ نشوند
      [-d, --download-only]
      فقط فایل‌ها دانلود شوند(unpacked یا نصب نشوند)
      [-f, --fix-broken]
      تلاش برای اصلاح گسیختگی‌های موجود در  وابستگی‌ها
      با این گزینه به برنامه apt اجازه داده می‌شود تا درصورت نیاز هر بسته‌ای را حذف نماید
      [-m, --ignore-missing, --fix-missing]
      نادیده گرفتن بسته‌‌های‌ خرابی(مثلا دانلود نمیشوند یا اینکه دانلود شده اند ولی خراب هستند)
      اگر بسته‌ها نمی‌توانند دانلود شوند یا بعد از دانلود امکان چک و بررسی یکپارچکی وجود نداردآن بسته‌ها را عقب نگه‌دار و نتیجه را هندل کن
      اگر این سوییچ را با -f استفاده نمایید ممکن است در  مواردی به ارور برخورد نمایید
      اگر نام یک بسته در خط فرمان برای نصب آورده شده باشد درصورت عدم دانلود این بسته بدون هیچ گونه اخطاری از نصب این بسته صرف نظر میشود
      [--no-download]
      فقط از بسته‌های deb موجود(کنونی) در سیستم‌عامل که پیش‌تر دانلود شده استفاده شود
      [-q, --quiet]
      این کامند برای تهیه لاگ بسیار مفید است زیرا نشانگرهای پیشرفت و موارد توضیحاتی را حذف می‌کند
      با مقداردهی به -q=# میتوانیم  سطح عدم تولید توضیحات را مشخص نماییم
      [-s, --simulate, --just-print, --dry-run, --recon, --no-act]
      هیچ کاری صورت نگیرد
      شبیه‌سازی و نمایش در خروجی از تغییراتی که با اجرای دستور صورت خواهد گرفت
      [-y, --yes, --assume-yes]
      بطور اتوماتیک به هر  prompt پاسخ yes خواهد داد
      run non-interactively
      در موارد نامطلوب دستور apt-get متوقف خواهد شد(نظیر: تغییر در نگهداری بسته یا نصب یک بسته غیرمجاز  یا حذف یک بسته خیلی مهم)
      [--assume-no]
      بصورت پیش‌فرض به  همه promp ها پاسخ no می‌دهد
      [--no-show-upgraded]
      عدم نمایش لیست تمام بسته‌هایی که آپگرید شده‌اند
      [-V, --verbose-versions]
      نمایش نسخه تمام نسخه‌ها از بسته‌هایی که آپگرید شده‌اند
      [-a, --host-architecture]
      بصورت پیش‌فرض تنظیم نیست
      در زمان استفاده از دستور apt-get source --compile معماری بسته‌های build شونده کنترل و  cross-builddependencies تامین شوند
      [-b, --compile, --build]
      Compile source packages after downloading them.
      [--ignore-hold]
      Ignore package holds;
      بسته را نگهداری ننماید-به عبارتی پس از نصب آن را در سیستم نگه‌ندارد
      [--with-new-pkgs]
      این سوییچ وقتی با دستور upgrade همراه شود دراین صورت مجاز به نصب بسته‌های جدید خواهد بود.
      این دستور زمان نیازمندی به یک dependency مفید خواهد بود تا آن نیز بتواند نصب نماید
      نکته:دستور upgrade هیچگاه بسته‌ای را حذف نمی‌کند و فقط بسته جدید را نصب می‌کند
      [--no-upgrade]
      Do not upgrade packages;
      همراه با دستور  install : اگر بسته هم‌اکنون نصب شده باشد آنگاه از  upgrade آن دستور جلوگیری بعمل خواهد آمد
      [--only-upgrade]
      همراه با دستور  install : اگر بسته هم‌اکنون در سیستم‌عامل موجود نباشد، نصب صورت نگیرد
      تنها زمانی بسته را آپگرید خواهد کرد که درحال حاضر بسته در سیستم‌عامل وجود داشته و ورژن جدید از آن در دسترس باشد
      [--allow-downgrades]
      این دستور خطرناک است و ممکن است به سیستم عامل آسیب برساند
      تنها در موارد خاص کاربرد دارد و در صورت دانلود ممکن است پیغامی ظاهر نشود
      [--allow-remove-essential]
      این دستور خطرناک است و ممکن است به سیستم عامل آسیب برساند
      بله(Force yes) به حذف دستوراتی که بعنوان پایه در سیستم عامل کاربرد دارند
      [--force-yes]
      بله(Force yes) به تمامی پیغام‌ها
      این دستور منقرض شده است و با دستورات
        --allow-downgrades, --allow-remove-essential, --allow-change-held-packages 
      جایگزین شده است
      [--print-uris]
      بجای اینکه فایل‌ها نصب شوند آدرس URL آن پرینت می‌شود
      هر URL دارای path و destination file name و سایز و کد MD5 است
      sudo apt-get install aptitude --print-uris
      [sudo] password for behrooz: 
      Reading package lists. Done
      Building dependency tree       
      Reading state information. Done
      The following additional packages will be installed:
        aptitude-common libclass-accessor-perl libcwidget3v5 libio-string-perl libparse-debianchangelog-perl libsub-name-perl
      Suggested packages:
        aptitude-doc-en | aptitude-doc apt-xapian-index debtags libcwidget-dev libhtml-template-perl libxml-simple-perl
      The following NEW packages will be installed:
        aptitude aptitude-common libclass-accessor-perl libcwidget3v5 libio-string-perl libparse-debianchangelog-perl libsub-name-perl
      0 upgraded, 7 newly installed, 0 to remove and 38 not upgraded.
      Need to get 3,494 kB of archives.
      After this operation, 15.8 MB of additional disk space will be used.
      'http://deb.debian.org/debian/pool/main/a/aptitude/aptitude-common_0.8.7-1_all.deb' aptitude-common_0.8.7-1_all.deb 1592678 MD5Sum:944f23494615284543660e9ee02c6c6d
      'http://deb.debian.org/debian/pool/main/c/cwidget/libcwidget3v5_0.5.17-4+b1_amd64.deb' libcwidget3v5_0.5.17-4+b1_amd64.deb 312582 MD5Sum:153078784a4cac12829bfb967cd9b8c4
      'http://deb.debian.org/debian/pool/main/a/aptitude/aptitude_0.8.7-1_amd64.deb' aptitude_0.8.7-1_amd64.deb 1477860 MD5Sum:3bd5df11a809e76d0e925e705b0f9f06
      'http://deb.debian.org/debian/pool/main/libs/libsub-name-perl/libsub-name-perl_0.21-1_amd64.deb' libsub-name-perl_0.21-1_amd64.deb 13122 MD5Sum:d2ae0127b9770f1511f9d8d6e65c415a
      'http://deb.debian.org/debian/pool/main/libc/libclass-accessor-perl/libclass-accessor-perl_0.34-1_all.deb' libclass-accessor-perl_0.34-1_all.deb 25950 MD5Sum:e8d44fcd57dcb4a39e53f7956b30dd22
      'http://deb.debian.org/debian/pool/main/libi/libio-string-perl/libio-string-perl_1.08-3_all.deb' libio-string-perl_1.08-3_all.deb 12298 MD5Sum:8d09424a4c3ba34a8ff890af95391947
      'http://deb.debian.org/debian/pool/main/libp/libparse-debianchangelog-perl/libparse-debianchangelog-perl_1.2.0-12_all.deb' libparse-debianchangelog-perl_1.2.0-12_all.deb 59376 MD5Sum:52a19d38904388812afef8d78611e26e
      
       
      [--purge]
      اگر بجای remove استفاده شود در این صورت همه چیز را پاک خواهد کرد
      [--reinstall]
      نصب مجدد بسته‌های که هم‌اکنون نصب شده است(در ورژن بالاتر)
      [--list-cleanup]
      بطور پیش‌فرض این سوییچ در دستور تعبیه شده است
      درصورت روشن بودن دستور apt  بطور اتوماتیک محتوی /var/lib/apt/lists  مدیریت را مدیریت کرده و اطمینان حاصل می‌گردد که فایل‌های منسوخ پاک شده باشد
      تنها دلیلی که این ویژگی را می‌توان خاموش کرد این استکه این فایل بطور مداوم تغییر می‌نماید
      نکته: از سوییچ  --no-list-cleanup برای خاموش کردن آن استفاده می‌شود
      [--no-remove]
      اگر هر بسته‌ای بخواهد حذف شود دستور apt-get همان موقع بدون اینکه pronpt بدهد قطع می‌شود
      [--auto-remove, --autoremove]
      Remove automatically all unused packages that were automatically installed to satisfy dependencies for other packages and are now no longer needed as dependencies changed
      [--only-source]
      تنها در دستورات buil-dep و  source معنی پیدا می‌کند.
      نشان میدهد که نام سورس داده شده به فایل‌های باینری مپ نشده باشد و دستورات تنها  نام بسته‌های سورس را بعنوان آرگومان قبول نمایند
      [--allow-unauthenticated]
      Ignore if packages can't be authenticated and don't prompt about it.
      This can be useful while working with local repositories, but is a huge security risk if data authenticity isn't ensured in another way by the user itself.
      The usage of the Trusted option for sources.list(5) entries should usually be preferred over this global override.
      [--no-allow-insecure-repositories]
      در دستور update ، از گرفتن دیتا‌ی verified نشده جلوگیری بعمل می‌آورد
      دستور apt update در صورت مواجهه با  ریپوزیتوری‌هایی با امضای رمز شده غیر معتبر ، fail می‌شود
      [--show-progress]
      نمایش نوار میزان پیشرفت کار در حین نصب با پاک یا آپگرید
      [--with-source filename]
      Adds the given file as a source for metadata. Can be repeated to add multiple files. See --with-source description in apt-cache(8) for further details.
      [-c, --config-file]
      Specify a configuration file to use.
      The program will read the default configuration file and then this configuration file.
      If configuration settings need to be set before the default configuration files are parsed specify a file with the APT_CONFIG environment variable. See apt.conf(5) for syntax information.
       

       

      FILES

      /etc/apt/sources.list:
      Locations to fetch packages from. Configuration Item: Dir::Etc::SourceList.
      /etc/apt/sources.list.d/:
      File fragments for locations to fetch packages from. Configuration Item: Dir::Etc::SourceParts.
      /etc/apt/apt.conf:
      APT configuration file. Configuration Item: Dir::Etc::Main.
      /etc/apt/apt.conf.d/:
      APT configuration file fragments. Configuration Item: Dir::Etc::Parts.
      /etc/apt/preferences:
      Version preferences file. This is where you would specify "pinning", i.e. a preference to get certain packages from a separate source or from a different version of a distribution. Configuration Item:[Dir::Etc::Preferences].
      /etc/apt/preferences.d/:
      File fragments for the version preferences. Configuration Item: Dir::Etc::PreferencesParts.
      /var/cache/apt/archives/:
      Storage area for retrieved package files. Configuration Item: Dir::Cache::Archives.
      /var/cache/apt/archives/partial/:
      Storage area for package files in transit. Configuration Item: Dir::Cache::Archives (partial will be implicitly appended)
      /var/lib/apt/lists/:
      Storage area for state information for each package resource specified in sources.list(5) Configuration Item: Dir::State::Lists.
      /var/lib/apt/lists/partial/:
      Storage area for state information in transit. Configuration Item: Dir::State::Lists (partial will be implicitly appended)
       
       
       
       
      • برای نمایش آدرس URL یک بسته ای که در هنوز در سرور نصب نیست
      apt-get -y install --print-uris <PackageName> | cut -f 2 -d \' | grep \.deb

       

       

       


      DNS

      Resolve:

      systemd-resolve -t MX gmail.com   #show mail server

      systemd-resolve -t SOA gmail.com   #show SOA .     Start Of Authority (More administrative information)   URL

      systemd-resolve 85.214.157.7        #Get domain name

      nslookup domain.ir [#Finding The IP Address of an Host from default dns server]

      nslookup domain.ir 8.8.8.8[#Finding The IP Address of an Host From non default dns server]

      nslookup -querytype=mx domain.ir[ #Find Mail Servers for a Domain]

      nslookup -query=mx domain.ir [#Find Mail Servers]

      nslookup -query=ns domain.ir [ #Find NameServers]

      nslookup -query=soa domain.ir [ #display the SOA record (information about the domain]

      nslookup -query=any domain.ir [ #display all the available DNS records]

      host -la domain.com [Show all record with Information]

      dig Domain.it axfr [Show all record with Information]

      systemd-resolve --statistics          #informations

       

      Flush the DNS Cache   URL

      Method 1: Using systemd-resolve to flush DNS-Cache

      sudo systemd-resolve --flush-caches

      sudo systemd-resolve --statistics

       

      Method 2: Using dns-clean to flush DNS-Cache

      sudo /etc/init.d/dns-clean start

       

       

       


      DNS

      Resolve:

      systemd-resolve -t MX gmail.com   #show mail server

      systemd-resolve -t SOA gmail.com   #show SOA .     Start Of Authority (More administrative information)   URL

      systemd-resolve 85.214.157.7        #Get domain name

      nslookup domain.ir [#Finding The IP Address of an Host from default dns server]

      nslookup domain.ir 8.8.8.8[#Finding The IP Address of an Host From non default dns server]

      nslookup -querytype=mx domain.ir[ #Find Mail Servers for a Domain]

      nslookup -query=mx domain.ir [#Find Mail Servers]

      nslookup -query=ns domain.ir [ #Find NameServers]

      nslookup -query=soa domain.ir [ #display the SOA record (information about the domain]

      nslookup -query=any domain.ir [ #display all the available DNS records]

      host -la domain.com [Show all record with Information]

      dig Domain.it axfr [Show all record with Information]

      systemd-resolve --statistics          #informations

       

      Flush the DNS Cache   URL

      Method 1: Using systemd-resolve to flush DNS-Cache

      sudo systemd-resolve --flush-caches

      sudo systemd-resolve --statistics

       

      Method 2: Using dns-clean to flush DNS-Cache

      sudo /etc/init.d/dns-clean start

       

       

      Resolve.conf

      Install:

      sudo apt install resolvconf

      For fix and NotChange file:

      vim  /etc/NetworkManager/NetworkManager.conf

      #Add below to main area :

      dns=none

       


      Check the number of attached disks

      # cat /proc/scsi/scsi | egrep -i 'Host:' | wc -l
      7

      verify Using /sys class file

      (- - -)

      $ echo "- - -" >  /sys/class/scsi_host/host0/scan
      #("- - -") of the command act as wildcards meaning rescan everything​​
      

      (c t l)

      $ echo "c t l" >  /sys/class/scsi_host/hosth/scan 
      # h is the HBA number
      # c is the channel on the HBA
      # t is the SCSI target ID
      # l is the LUN.
      

      #If you don't have the host bus number, you must list all the existing host bus number on your system with the command

      $ ls /sys/class/scsi_host
      host0 host1 host2
      
      $ echo "- - -" > /sys/class/scsi_host/host0/scan
      $ echo "- - -" > /sys/class/scsi_host/host1/scan
      $ echo "- - -" > /sys/class/scsi_host/host2/scan
      
      <OR>
      
      # for host in `ls /sys/class/scsi_host/`;do
       echo "- - -" >/sys/class/scsi_host/${host}/scan;
      done
      

       

       

      URL

       

       

       

       


      GIT

      نکات:

      • محیط استیج یعنی وضعیت آماده کامیت کردن

      • هد یکی از کامیت‌ها یا تغییرات پایداری است که در یک شاخه وجود دارد. معمولا آخرین کامییتی است که کرده ایم
      • نمایش تغییرات بر اساس برنامه diff -u انجام می‌گیرد.
      • اول همه فایل‌های untracked هستند یعنی گیت مواظب آنها نیست و بعد آن را add می‌کنیم و در اینصورت گیت آنها را میفهمد و مواظبت می‌کند یعنی میروند در محیط stage و بعدا آن را کامیت می‌کنیم و با این کار به محیط پایدار خواهند رسید
      • وقتی از یک سایتی یک پروژه راکلون می‌کنیم اسم کامیت پایدار (معمولا HEAD) آن پروژه را می‌گذاریم origin و همچنان اسم آخرین نسخه پایدار سیستم خودم هم master خواهد بود

      دستورات:

      • ساختن یک پروژه گیت خالی که یک فولدر مخفی ایجاد می‌کند
      $ git init
      • نمایش وضعیت فایل‌های موجود در پوشه ای که گیت آن پوشه را در اختیار گرفته است:
      $ git status
        • افزودن یک تغییر در استیج :
        $ git add <File>
          • افزودن یک تغییر در استیج:
          $ git add -A
          • انتقال تغییرات از استیج به کامیت:
          $ git commit -m "message"    
          • مشاهده کارهایی که کردید
          $ git log --stat --summary
          • مشاهده کارهایی که کردید با تفاوت دیف‌ها
          $ 111git log -p
          •  نمایش تغییرات کنونی با تغییرات هِد
          $ 111git diff HEAD 
          • فایل‌های محیط استیج چه تغییراتی داشته اند.-تفاوت هد و استیج را نشان می‌دهد
          $ git diff --staged
          $ git diff --color
          •  یک فایل را از استیج  بیرون بیاور
          $ git reset file
          • بازگشت به آخرین تغییرات در آن فایل-با این کار فایل اصلی که در هد است جایگزین فایلی می‌شود که در آن تغییرات اشتباه داده بودید
          $ git checkout -- <FILE>
          • نمایش تمامی برنچ‌های موجود
          $ git branch
          • ساختن یک برنج جدید
          $ git branch <Name>
          • رفتن به برنچ دیگر(بکش بیرون اون رو)
          $ git checkout  <branchName>
          • برنجی که هِد در آن است را با برنج ذکر شده یکی می‌کند
          $ git merge <branchName>
          • پاک کردن یک فایل از گیت و فایل‌سیستم
          $ git rm <file>
          • پاک کردن یک برنچ
          $ git branch -d <BranchName> 
          • کلون کردن یک پروژه در سیستم خود
          $ git clone <URL.git>
          • پروژه ای که از سایت گرفتم را تغییر دادم. این تغییرات در شاخه مَستر سیستم خودم انجام گرفته است. اگر بخواهم این تغییرات را در برنچ اصلی سایت قرار بدهم باید از این دستور کمک بگیرم
          $ git push origin master
          • آخرین تغییراتی که در سایت وجود دارد که با نام اوریجین شناخته می‌شود را  بگیرد و در شاخه مَستر سیستم خودم اَعمال کن
          $ git pull origin master 
          • وضعیت را در سرور گیت نشان میدهد=============>باید بررسی شود
          $ git remote 
          • از پروژه فعلی یک ریپوزیتوری در سرور ایجاد کن و اسم آن را بگذار اوریجین و آدرس آن را هم باید ادمین سرور گیت به ما بدهد
          $ git remote add  origin  URL 
          • تغییرات مستر را به شاخه اوریجین که  در  سرور است اضافه کن
          $ git push origin master 
          • نشان دادن تغییرات یک کامیت
          $ git show <Hash Of Commit>
          • نمایش جزییات یک تگ که بعنوان ورژن شناخته می‌شود
          $ git shwo <tag name>
          • نکته: tag می‌تواند به ما بگوید که کدام کامیت است که قابلیت ارائه به مشتری را دارد. یعنی مدیر پروژه در ذهن خودش حفظ نکند که کدام ورژن شماره یک است و کدام شماره نسخه دوم از برنامه است. معمولا شرکت‌ها برای اینکه یک release از محصول بدهند در کامیت مطلوب یک تگ میزنند که تحت عنوان ورژن شماره خاص از محصول شناخته بشود.
          • نکته: تگ بر روی کامیت زده می‌شود
          • نمایش تگ‌ها
          $ git tag
          • زدن تک به آخرین کامیت    
          $ git tag -a v2.0.1 -m " توضیحات در باره این تگ"
          • به یک کامیت قدیمی یک تگ اختصاص دادیم
          $ git tag -a v1.3.9 <Hash Of custom commit> -m "توضیحات درباره تک"
          • نمایش تمام تگ‌هایی که در اول آن کاراکتر "وی" قرار دارد
          $ git tag -l "v*"
          • نکته: اگر تغییر از نوع ایجاد تگ باشد، گیت آن را نمی‌فهمد. یعنی دستور git status ایجاد تگ را گزارش نمی‌دهد.(در نتیجه در دستور پوش هم چیزی به سرور اضافه نخواهد شد)
          • تگ مورد نظر را به شاخه اوریجین در سرور اضافه  کند
          $ git push origin <TagName>
          • تگ‌ها را به شاخه اوریجین در سرور گیت اضافه کن
          $ git push origin --tags
          • رفتن به یک تگ(یعنی کامیتی که در آن تگ زده شده) در پروژه
          $ git checkout <Tag name>
          • نکته: اگر به یک تگ checkout کردیم برای ایجاد تغییرات باید یک برنچ ایجاد نماییم و تغییرات را به آن اعمال نماییم.
          • نمایش نام کاربری گیت
          $ git config --global user.name
          • تاریخچه تغییرات فایل را نشان می‌دهد
          $ git blame <FileName>
          • تاریخچه تغییرات لاین هشتم از فایل را نشان می‌دهد
          $ git blame <FileName> -L8
          • تاریخچه تغییرات لاین هشتم تا لاین دهم  از فایل را نشان می‌دهد(نفر آخری که تغییرات را ایجاد کرده است)در پروژه
          $ git blame <FileName> -L8,10
          • نکته: وقتی یک باگ در یک فایل پیدا می‌کنیم git blame اجازه می‌دهد که آن را گردن یکی بیاندازید.
          • برخی تنظیمات
          $ git config --global user.name "Your Full Name"
          $ git config --global user.email you@somewhere.com
          • بازگشت به آخرین کامیت(اگر استیج نشده باشد یعنی دستور اَد زده نشده باشد)
          $ git checkout -- filename
          • بازگشت به آخرین کامیت درصورتی که دستور اَد زده شده باشد
          $ git reset HEAD filename
          •  

            اگر جندین کارت شبکه را به جهت افزایش troughtPut و bandwidth به هم پیوند بدهیم و در نتیجه خروجی حاصله برابر جمع پهنای باندها(هریک به تنهایی) بشود در این صورت از تکنیک bond استفاده شده است:

             

             

             

            modprobe bonding
            ifconfig eth0 down
            ifconfig eth1 down
            ifconfig bond0 up
            ifenslave bond0 eth0 eth1
            ifconfig bond0 192.168.0.1 netmask 255.255.255.0
            ifconfig eth0 up
            ifconfig eth1 up
            ----------------------------------------
            # ip link add bond0 type bond
            # ip link set bond0 type bond miimon 100 mode active-backup
            # ip link set em1 down
            # ip link set em1 master bond0
            # ip link set em2 down
            # ip link set em2 master bond0
            # ip link set bond0 up

            URL1

            URL2

            URL3


            ماژول  pam_access.so  در لینوکس وجود دارد ولی به کرنل اضافه نشده است و باید برای ایجاد محدودیت آن را به کرنل اضافه نماییم

            برای اینکار:

            $ vim /etc/security/access.conf:
               #add role:
               + : root : ALL
            $ vi /etc/pam.d/password-auth
               account <tab> required <tab> pam-access.so
            

            نکته: می‌توان از syntax فایل login موجود در مسیر pam.d موجود در مسیر etc استفاده کرد


            GIT

            نکات:

            • محیط استیج یعنی وضعیت آماده کامیت کردن

            • هد یکی از کامیت‌ها یا تغییرات پایداری است که در یک شاخه وجود دارد. معمولا آخرین کامییتی است که کرده ایم
            • نمایش تغییرات بر اساس برنامه diff -u انجام می‌گیرد.
            • اول همه فایل‌های untracked هستند یعنی گیت مواظب آنها نیست و بعد آن را add می‌کنیم و در اینصورت گیت آنها را میفهمد و مواظبت می‌کند یعنی میروند در محیط stage و بعدا آن را کامیت می‌کنیم و با این کار به محیط پایدار خواهند رسید
            • وقتی از یک سایتی یک پروژه راکلون می‌کنیم اسم کامیت پایدار (معمولا HEAD) آن پروژه را می‌گذاریم origin و همچنان اسم آخرین نسخه پایدار سیستم خودم هم master خواهد بود

            دستورات:

            • ساختن یک پروژه گیت خالی که یک فولدر مخفی ایجاد می‌کند
            $ git init
            • نمایش وضعیت فایل‌های موجود در پوشه ای که گیت آن پوشه را در اختیار گرفته است:
            $ git status
              • افزودن یک تغییر در استیج :
              $ git add <File>
                • افزودن یک تغییر در استیج:
                $ git add -A
                • انتقال تغییرات از استیج به کامیت:
                $ git commit -m "message"    
                • مشاهده کارهایی که کردید
                $ git log --stat --summary
                • مشاهده کارهایی که کردید با تفاوت دیف‌ها
                $ 111git log -p
                •  نمایش تغییرات کنونی با تغییرات هِد
                $ 111git diff HEAD 
                • فایل‌های محیط استیج چه تغییراتی داشته اند.-تفاوت هد و استیج را نشان می‌دهد
                $ git diff --staged
                $ git diff --color
                •  یک فایل را از استیج  بیرون بیاور
                $ git reset file
                • بازگشت به آخرین تغییرات در آن فایل-با این کار فایل اصلی که در هد است جایگزین فایلی می‌شود که در آن تغییرات اشتباه داده بودید
                $ git checkout -- <FILE>
                • نمایش تمامی برنچ‌های موجود
                $ git branch
                • ساختن یک برنج جدید
                $ git branch <Name>
                • رفتن به برنچ دیگر(بکش بیرون اون رو)
                $ git checkout  <branchName>
                • تنها مشاهده تغییرات سرور آنلاین(ریموت)- نکته: تغییرات به لوکال منتقل نمی‌شود
                $ git fetch origin
                • پس از اینکه با دستور fetch‌ صحت تغییرات مخزن آنلاین را مشاهده کردیم،‌ آن را با دستور زیر از مخزن آنلاین  به لوکال منتقل می‌کنیم.(حتما باید نام برنج آورده بشود)
                $ git merge origin/master
                • برنجی که هِد در آن است را با برنج ذکر شده یکی می‌کند
                $ git merge <branchName>
                
                • پاک کردن یک فایل از گیت و فایل‌سیستم
                $ git rm <file>
                • حذف فایل stage شده موجود و تبدیل به unstage
                $ git rm --cached <FileNames>
                • حذف فولدر  stage شده موجود و تبدیل به unstage
                $ git rm --cached -r <FOLDER>
                • پاک کردن یک برنچ
                $ git branch -d <BranchName> 
                • کلون کردن یک پروژه در سیستم خود
                $ git clone <URL.git>
                • پروژه ای که از سایت گرفتم را تغییر دادم. این تغییرات در شاخه مَستر سیستم خودم انجام گرفته است. اگر بخواهم این تغییرات را در برنچ اصلی سایت قرار بدهم باید از این دستور کمک بگیرم
                $ git push origin master
                • آخرین تغییراتی که در سایت وجود دارد که با نام اوریجین شناخته می‌شود را  بگیرد و در شاخه مَستر سیستم خودم اَعمال کن
                $ git pull origin master 
                • وضعیت را در سرور گیت نشان میدهد=============>باید بررسی شود
                $ git remote 
                • از پروژه فعلی یک ریپوزیتوری در سرور ایجاد کن و اسم آن را بگذار اوریجین و آدرس آن را هم باید ادمین سرور گیت به ما بدهد
                $ git remote add  origin  URL 
                • تغییرات مستر را به شاخه اوریجین که  در  سرور است اضافه کن
                $ git push origin master 
                • نشان دادن تغییرات یک کامیت
                $ git show <Hash Of Commit>
                • نمایش جزییات یک تگ که بعنوان ورژن شناخته می‌شود
                $ git shwo <tag name>
                • نکته: tag می‌تواند به ما بگوید که کدام کامیت است که قابلیت ارائه به مشتری را دارد. یعنی مدیر پروژه در ذهن خودش حفظ نکند که کدام ورژن شماره یک است و کدام شماره نسخه دوم از برنامه است. معمولا شرکت‌ها برای اینکه یک release از محصول بدهند در کامیت مطلوب یک تگ میزنند که تحت عنوان ورژن شماره خاص از محصول شناخته بشود.
                • نکته: تگ بر روی کامیت زده می‌شود
                • نمایش تگ‌ها
                $ git tag
                • زدن تک به آخرین کامیت    
                $ git tag -a v2.0.1 -m " توضیحات در باره این تگ"
                • به یک کامیت قدیمی یک تگ اختصاص دادیم
                $ git tag -a v1.3.9 <Hash Of custom commit> -m "توضیحات درباره تک"
                • نمایش تمام تگ‌هایی که در اول آن کاراکتر "وی" قرار دارد
                $ git tag -l "v*"
                • نکته: اگر تغییر از نوع ایجاد تگ باشد، گیت آن را نمی‌فهمد. یعنی دستور git status ایجاد تگ را گزارش نمی‌دهد.(در نتیجه در دستور پوش هم چیزی به سرور اضافه نخواهد شد)
                • تگ مورد نظر را به شاخه اوریجین در سرور اضافه  کند
                $ git push origin <TagName>
                • تگ‌ها را به شاخه اوریجین در سرور گیت اضافه کن
                $ git push origin --tags
                • رفتن به یک تگ(یعنی کامیتی که در آن تگ زده شده) در پروژه
                $ git checkout <Tag name>
                • نکته: اگر به یک تگ checkout کردیم برای ایجاد تغییرات باید یک برنچ ایجاد نماییم و تغییرات را به آن اعمال نماییم.
                • نمایش نام کاربری گیت
                $ git config --global user.name
                • تاریخچه تغییرات فایل را نشان می‌دهد
                $ git blame <FileName>
                • تاریخچه تغییرات لاین هشتم از فایل را نشان می‌دهد
                $ git blame <FileName> -L8
                • تاریخچه تغییرات لاین هشتم تا لاین دهم  از فایل را نشان می‌دهد(نفر آخری که تغییرات را ایجاد کرده است)در پروژه
                $ git blame <FileName> -L8,10
                • نکته: وقتی یک باگ در یک فایل پیدا می‌کنیم git blame اجازه می‌دهد که آن را گردن یکی بیاندازید.
                • برخی تنظیمات
                $ git config --global user.name "Your Full Name"
                $ git config --global user.email you@somewhere.com
                • بازگشت به آخرین کامیت(اگر استیج نشده باشد یعنی دستور اَد زده نشده باشد)
                $ git checkout -- filename
                • بازگشت به آخرین کامیت درصورتی که دستور اَد زده شده باشد
                $ git reset HEAD filename
                •  

                  آخرین ارسال ها

                  آخرین وبلاگ ها

                  آخرین جستجو ها