لینوکس و شبکه

لینوکس و شبکه
طبقه بندی موضوعی
آخرین مطالب
  • ۹۹/۱۱/۱۳
    java
۲۹
فروردين
1- sudo apt-get install openssh-client
2- ssh-keygen -t rsa
    . Enter file in which to save the key (/home/user/.ssh/id_rsa)
    . Enter passphrase (empty for no passphrase) # can donot use passphrass
    . Enter same passphrase again
3- check :
    . Public Key: /home/user/.ssh/id_rsa.pub
    . Private Key: /home/user/.ssh/id_rsa    

4- ssh-copy-id user@YourServerIPAddress    
or
cat ~/.ssh/id_rsa.pub | ssh User@YourServerIPAddress “mkdir -p ~/.ssh && cat >>  ~/.ssh/authorized_keys”
or
scp /home/user/.ssh/id_rsa.pub  user@YourServerIPAddress:/home/user/.ssh
  • behrooz mohamadi nsasab
۱۸
اسفند

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

 

 

 

grub page> press e
grub page> linux /boot/vmlinuz-4.8.0 root=/dev/sda7 ro init=/bin/bash
grub page> ctrl+x
bash
mount -rw -o remounr /
  • behrooz mohamadi nsasab
۲۵
بهمن
sudo apt install builde-essential software-properties-common sshpass git htop icedtea-netx torsocks tor resolvconf python3-pip \
 bash-completion unzip bzip2 mlocate lshw net-tools shellinabox telnet bash nmap bc openjdk sudo wget curl ftp parted* gparted \
 socat  nload
sudo yum groupinstall 'Development Tools'
sudo yum install icedtea-web  git sshpass firewalld  bash-completion torsocks unzip bzip2 mlocate lshw \
 net-tools shellinabox telnet  tor bash  kernel-tools* linux-firmware openssh openssh-server openssh-client \
 nmap bc  java-11-openjdk-devel ftp ftplib vim kernel-devel kernel-headers  yum-utils wget curl sudo lsof \
 parted* socat nload
  • behrooz mohamadi nsasab
۱۴
بهمن

قصد داریم از طریق پروکسی به یک سرور که اینترنت ندارد اینترنت بدهیم

 

سیستم بدون اینترنت:  192.168.10.173

سیستم دارای اینترنت: 192.168.10.148 با یوزر behrooz

 

yum

این دو دستور را درسرور 192.168.10.173 وارد نمایید:

1-add to /etc/yum.conf:
  proxy=socks5h://localhost:xxxx

2-ssh -N -D XXXX behrooz@192.168.10.148

URL

 

 

 

APT

دستورات را درسرور 192.168.10.173 وارد نمایید:

1-vim /etc/apt/apt.conf.d/behrooz
  Acquire::http::proxy "socks5h://localhost:XXXX";
2-ssh -N -D XXXX behrooz@192.168.10.148

URL

  • behrooz mohamadi nsasab
۱۳
بهمن

مراحل نصب یک نسخه جدید از جاوا

شناساندن جاوا(JRE)

sudo update-alternatives --install "/usr/bin/java" "java" "<Custom PATH>/bin/java" 0

شناساندن جاوا(JDK)

sudo update-alternatives --install "/usr/bin/javac" "javac" "<Custom PATH>/bin/javac" 0

شناساندن جاوا (Web Start)

sudo update-alternatives --install "/usr/bin/javaws" "javaws" "<Custom PATH>/bin/javaws" 0

 

نکته‌مهم

 در ورژن‌های شماره ۷ یا ۸  مورد javaws یا java web start وجود داشت ولی در ورژن‌های بالاتر این مورد وجود ندارد که برای این کار با نصب بسته icedtea می‌توانیم javaws را به سیستم معرفی کنیم

sudo apt install icedtea-netx 
sudo yum install icedtea-web

در این صورت برنامه های با فرمت jnlp می‌توانیم با دستور زیر اجرا نماییم

/usr/bin/javaws /tmp/launch.jnlp 

 

مشاهده گانفیگ فعلی جاوا

java -version
sudo update-alternatives --list java
sudo update-alternatives --list javac
sudo update-alternatives --list javaws

 

 

کانفیگ کردن یک جاوای جدید

اگر هیج جاوایی در سیستم نداشته باشیم همان اولین جاوا بعنوان پیش فرض تلقی خواهد شود ولی اگر از پیش جاوا با نسخه دیگری درسیستم موجود باشد باید تنظیمات را از جاوای نسحه قبل به جاوای نسخه جدید منتقل نماییم:

sudo update-alternatives --config java
sudo update-alternatives --config javac
sudo update-alternatives --config javaws

یا به روش زیر عمل نماییم

sudo update-alternatives --set java  <PATH>
sudo update-alternatives --set javac <PATH>
sudo update-alternatives --set javaws <PATH>

 

حذف یک نسخه از جاوا

برای حذف یک نسخه از جاوا بهتر است از دستور زیر اقدام نمایید

گام اول: مشاهده نسخه ها به همراه مسیرهای آنها

java -version
sudo update-alternatives --list java
sudo update-alternatives --list javac
sudo update-alternatives --list javaws

گام دوم: حذف نسخه مورد نظر توسط ارائه مسیر آن ورژن

sudo update-alternatives --remove java <Path>
sudo update-alternatives --remove javac <Path>
sudo update-alternatives --remove javaws <Path>

example:
sudo update-alternatives --remove java /opt/java8/bin/java

گام سوم: تعیین نسخه مطلوب باقیمانده از نسخه‌های جاوا بعنوان پیش‌فرض

sudo update-alternatives --config java
sudo update-alternatives --config javac
sudo update-alternatives --config javaws

 

 

 

 

 

 

 

 

 

 

  • behrooz mohamadi nsasab
۰۴
بهمن

دستور زیر یک عبارت را به رمزنگاری تبدیل میکند

$ echo "salam" | base64
output:
       c2FsYW0K

$ base64 -d <<< c2FsYW0K
output:
       salam

 

 

 

 

 

  • behrooz mohamadi nsasab
۲۱
دی

برای pars کردن یک عبارت json می‌توان از دستور زیر که تلفیقی از کد پایتون نیز می‌باشد استفاده نمود

 

echo '{"hostname":"test","domainname":"example.com"}' | python -c 'import json,sys;obj=json.load(sys.stdin);print obj["hostname"]'

 

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

  • behrooz mohamadi nsasab
۱۴
آبان

دستور شیفت در اسکریپت نویسی:

  • دستور شیفت فقط یک عدد بعنوان آرگومان می‌پذیرد
  • دستور شیفت عددی بین صفر تا تعداد آرگومان می‌پذیرد
  • در دستور شیفت عدد صفر هیچ کاری نمی‌کند
  • اگر خط شیفت با عدد ۱ اجرا بشود. آنگاه آرگومان یک را نادیده گرفته و آرگومان شماره دو بعنوان آرگومان شماره یک، تلقی خواهد شد
shift 1
  • گر خط شیفت با عدد ۲ اجرا بشود. آنگاه آرگومان یک و دو  نادیده گرفته شده و آرگومان شماره سه بعنوان آرگومان شماره یک، تلقی خواهد شد
shift 2
  • گر خط شیفت با عدد پنج اجرا بشود. آنگاه آرگومان یک و دو وسه و چهار و پنج  نادیده گرفته و آرگومان شماره شش بعنوان آرگومان شماره یک، تلقی خواهد شد
shift 5
  • بطور خلاصه می‌توان گفت «به اندازه عدد داده شده به دستور شیفت» آرگومان ورودی را حذف کرده و آرگومان بعدی را بعنوان یک درنظر خواهد گرفت
  •  

 

  • behrooz mohamadi nsasab
۰۲
شهریور
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

 

 

 

  • behrooz mohamadi nsasab
۰۲
شهریور

نصب برنامه‌های زیر:

sudo apt install tor torsocks

استفاده به دو حالت زیر:

1-Temporary:
     torsocks COMMAND 
Example:
     curl https://showip.net

 

2-Permanent over shell
     . torsocks  on
Example
     curl https://showip.net

با استفاده از هر دو روش بالا موجب خواهد شد که آی پی حقیقی شما در پس یک آی پی دیگر مخفی شود.

 

 

  • behrooz mohamadi nsasab
۱۱
خرداد

برای نمایش وضعیت یک پردازه بکار می‌رود. مثلاْ آگاهی از برخی پارامتر‌های یک عمل کپی در حین اجرا. مثلا:

  • مقدار زمان گذشته و زمان واقعی صرف شده بین شروع و پایان 
  • درصد انجام کار (همچنین یک پروسس بار نمایش می‌دهد)
  • مقدار نرخ throughput
  • مقدار دیتای ارسال شده
  • تخمین زمان پایان

نصب:

# sudo yum install pv
# sudo apt install pv 

 

کپی یک فایل درون فولدر Download :

# pv CentOS7.iso > Downloads/centos.iso

 

 

ایجاد محدودیت برای اینکه فایل را با نرخ دومگابایت در ثانبه ارسال نماید

$ pv -L 2m CentOS7.iso > Downloads/centos.iso    # limitation 2MB per second

 

 

درصورتی که چندین فایل موجود باید میتوانیم توسط دستور زیر از آنها فایل آرشیو بسازیم

# tar c Notebooks/ | pv | tar x -C Documents/

 

ایجاد یک فایل آرشیو

# pv CentOS7.iso | zip > centos.zip

 

استفاده بین ورودی و خروجی دستور dd

# dd if=CentOS7.iso | pv | dd of=Downloads/centos7.iso

 

 

نمایش دیالوگ باکس در حین ایجاد یک فایل آرشیو

tar -czf - Official/ | (pv -n > mybackup.tgz) 2>&1 | dialog --gauge "Compressing files, please wait..." 10 70 0

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

URL

 

 

 

 

 

 

  • behrooz mohamadi nsasab
۱۴
اسفند

اگر جندین کارت شبکه را به جهت افزایش 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

  • behrooz mohamadi nsasab
۱۴
اسفند

ماژول  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 استفاده کرد

  • behrooz mohamadi nsasab
۱۴
دی

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

 

 

 

 

  • behrooz mohamadi nsasab
۰۲
دی

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 openvpn 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

  • behrooz mohamadi nsasab
۰۱
دی

نمایش اطلاعات سرور پی اچ پی

  • http://192.168.40.42/?/Info
  • behrooz mohamadi nsasab
۰۱
دی

در آموزش زیر :
    آدرس شبکه :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

  • behrooz mohamadi nsasab
۰۹
شهریور

$ systemctl get-default                                         #show current default target for UI(Gnome or another UI)

$ systemctl set-default graphical.target               #set gui instead cli (change runlevel from 3 to 5)

or

rm '/etc/systemd/system/default.target'

ln -s /usr/lib/systemd/system/graphical.target   /etc/systemd/system/default.target

 

 

  • behrooz mohamadi nsasab
۱۶
مرداد

${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

  • behrooz mohamadi nsasab
۱۲
مرداد

ps

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

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

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

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

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

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

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

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

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

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

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

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

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


ps -el

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

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

  • behrooz mohamadi nsasab
۰۱
مرداد


!! 

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.

  • behrooz mohamadi nsasab
۲۱
تیر

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 “xxxpingxxx”
[-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.

  • behrooz mohamadi nsasab
۱۶
تیر

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

 

 

 

  • behrooz mohamadi nsasab
۱۶
تیر

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)
  • behrooz mohamadi nsasab
۱۵
تیر

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

  • behrooz mohamadi nsasab
۲۶
خرداد

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

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

 

  • behrooz mohamadi nsasab
۰۸
خرداد

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

  • behrooz mohamadi nsasab
۲۳
ارديبهشت

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

 

  • behrooz mohamadi nsasab
۲۴
فروردين
[root@dlp ~]# yum --enablerepo=epel -y install xrdp				# install from EPEL
[root@dlp ~]# systemctl start xrdp 
[root@dlp ~]# systemctl enable xrdp 
[root@dlp ~]# firewall-cmd --add-port=3389/tcp --permanent    #If Firewalld is running, allow RDP port.
[root@dlp ~]# firewall-cmd --reload 

URL

  • behrooz mohamadi nsasab
۱۷
فروردين

تبدیل  jsonObject به Key=Value

$ cat test.json
{
    "var": 1,
    "foo": "bar",
    "x": "test"
}
$ jq -r "to_entries|map(\"\(.key)=\(.value|tostring)\")|.[]" test.json
foo=bar
var=1
x=test

 

curl -s 'https://api.github.com/users/lambda' | jq -r '.name'

 

URL

URL

URL

  • behrooz mohamadi nsasab
۲۶
اسفند

  • 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

  • behrooz mohamadi nsasab
۲۱
اسفند

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


  • behrooz mohamadi nsasab
۲۰
اسفند

    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]

    • behrooz mohamadi nsasab
    ۲۰
    اسفند

    • yum install curlftpfs             [# if error: yum install fuse ]
    • $ftphost = [FTP host]
    • $mount = [Mounted to folder]
    • $user = [FTP username]
    • $pass = [FTP password]
    • curlftpfs $ftphost $mount -o user=$user:$pass,allow_other     [# Mount the CurlFtpFS]
    • fusermount -u $mount      [# Unmount the CurlFtpFS]
                            • behrooz mohamadi nsasab
                            ۱۹
                            اسفند

                            [CENTOS7]-[DEBIAN9]:

                            SHOW:

                            • $ hostname
                            • $ hostname -s #displayed the computer short name
                            • $ hostname -f #displays the computer FQDN in the network
                            • $ cat /etc/hostname
                            • Add new hostname in /etc/hosts

                            CHANGE:

                            • hostnamectl set-hostname NAME
                            • hostnamectl #Show change config



                            • behrooz mohamadi nsasab
                            ۱۴
                            اسفند

                             

                             

                            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.xxx 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

                            • behrooz mohamadi nsasab
                            ۱۳
                            اسفند

                            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
                            • behrooz mohamadi nsasab
                            ۱۱
                            اسفند

                            سوکت‌های فعلی سرور که به هیچ فایلی از هارد وصل نشده است - پردازه‌های موجود در رم که ممکن است ویروس باشند

                            lsof +L1

                            • behrooz mohamadi nsasab
                            ۱۱
                            اسفند

                            نمایش همه ستون‌ها بجز ستون شماره یکم و ستون شماره دوم

                            cat FIle | awk '{$1=$2="";print$0}'

                            • behrooz mohamadi nsasab
                            ۰۴
                            اسفند

                            هر برنامه را که در این مسیر قرار بدهید در حین بالا آمدن آن کاربر به اجرا در خواهد آمد:

                            C:/users/AppData/Roaming/Microsoft/Windows/StartMenu/Programs/Startup


                            • behrooz mohamadi nsasab
                            ۰۴
                            اسفند

                            • نمایش اطلاعات سروری که در آن برنامه 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

                            • behrooz mohamadi nsasab
                            ۰۴
                            اسفند

                            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
                            • behrooz mohamadi nsasab
                            ۰۱
                            اسفند

                            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

                            • behrooz mohamadi nsasab
                            ۳۰
                            بهمن

                            برای راه اندازی وی پی ان از طریق terminal در لینوکس به روش زیر عمل مینماییم

                            modprobe nf_conntrack_pptp    # add pptp module to kernel
                            pppd call linuxconfig     # stablished Tunnel
                            route add default dev ppp0    #route all traffic to Tunnel

                            اسکریپت شده دستورات بالا:

                            #!/bin/bash
                            username=$1;
                            password=$2;
                            if [[ "$username" != "" && "$password" != "" ]]; then
                            echo "INSTALL STARTING ..."
                            # rpm -ivh pptp-1.7.2-22.el7.x86_64.rpm    #if is not install in server please install it
                            modprobe  nf_conntrack_pptp
                            echo "$username   PPTP    $password        *">/etc/ppp/pap-secrets
                            echo 'pty "pptp 10.10.10.10 --nolaunchpppd"    #10.10.10.10 Is Gateway's ip
                            name '$username'
                            remotename PPTP
                            #require-mppe-128
                            file /etc/ppp/options.pptp
                            ipparam linuxconfig'>/etc/ppp/peers/linuxconfig
                            echo 'lock
                            noauth
                            refuse-eap
                            refuse-chap
                            refuse-mschap
                            nobsdcomp
                            nodeflate'>/etc/ppp/options.pptp  #or comment refuse-pap line in tis file
                            pppd call linuxconfig
                            route add default dev ppp0
                            else
                            echo "please insert username password."
                            fi



                            نکته: یکی از dependency های اسکریپت بالا URL

                            دستورات بالا با دوفایل ارتباط دارد که این فایل‌ها وقتی بخواهیم بدون اسکریپت بالا پیکربندی کنیم به صورت زیر عمل خواهیم کرد.


                            vim /etc/ppp/peers/linuxconfig

                            pty "pptp 10.10.10.10 --nolaunchpppd" 
                            name USERNAME
                            remotename PPTP
                            #require-mppe-128
                            file /etc/ppp/options.pptp
                            ipparam linuxconfig


                            vim /etc/ppp/pap-secret

                            # Secrets for  authentication using PAP
                            # client server secret      IP addresses
                            username     PPTP    password     *

                            • behrooz mohamadi nsasab
                            ۱۱
                            بهمن

                            1. برنامه  open-vm-tools در لینوکس جهت همگام سازی ماشین مجازی با برنامه vmware می‌باشد(مشابه vmwareTools)
                            • behrooz mohamadi nsasab
                            ۱۰
                            بهمن

                            یک تجربه: در دبیان ۹ برای اینکه 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

                            • behrooz mohamadi nsasab
                            ۱۰
                            بهمن

                            بایستی در تنظیمات apache در فایل php.ini مقادیر post_max_size و upload_max_filesize را زیاد کرده (دقت شود که مقدار 
                            post_max_size بیشتر ازupload_max_filesize  باشد) و سپس سرویس آپاچی ریست شود


                            post_max_size

                            upload_max_filesize

                            • behrooz mohamadi nsasab
                            ۱۰
                            بهمن
                            برای تبدیل یک اسکریپت شل به فایل اجرایی که محتوی آن قابل نمایش نباشد از دستور زیر میتوان استفاده کرد
                            به عبارت دیگر دستور زیر فایل کامپایل شده را بصورت فایل اجرایی‌ای که محتوی قابل نمایش نیست در خواهد آورد


                            shc -f NAME.sh
                            • behrooz mohamadi nsasab
                            ۱۰
                            بهمن
                            توسط این برنامه می‌توان فایل یا متن از طریق شبکه منتقل نمود:

                            ۱-ارسال متن:

                            در گیرنده دستور زیر زده شود:
                            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



                            • behrooz mohamadi nsasab
                            ۱۰
                            بهمن

                              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;

                            • behrooz mohamadi nsasab
                            ۲۸
                            تیر
                            در فایل profile متن زیر را قرار دهید:
                            • vim /etc/profile
                            • export HISTTIMEFORMAT="%d/%m/%y %T "

                            • behrooz mohamadi nsasab
                            ۲۳
                            تیر
                            برای نمایش یک پیغام بصورت 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




                            • behrooz mohamadi nsasab
                            ۰۶
                            تیر
                            روش زیر اتصا ل یک مسیر اف تی پی به یک فولدر در سروررا توضیح میدهد
                            ابتدا بسته 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

                            • behrooz mohamadi nsasab
                            ۰۳
                            تیر
                            در لینوکس استفاده از پورت های کمتر از 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
                            • behrooz mohamadi nsasab
                            ۲۴
                            خرداد

                            اگر بخواهیم تنها عبارات سه حرفی را به نمایش بگذاریم از دستور زیر استفاده میکنیم

                            grep -x '.\{3,10\}'
                            • -x match pattern to whole line
                            • . any symbol
                            • {3,10} quantify from 3 to 10 times previous symbol (in the case any ones)

                            ایجاد یک فایل بک آپ از همان فایل با پسوند backup در همان مسیر فایل موجود

                            cp /etc/postfix/main.cf{,.backup}

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

                            set -x
                            

                            IF

                            Comparisons:

                            -eq equal to
                            -ne not equal to
                            -lt less than
                            -le less than or equal to
                            -gt greater than
                            -ge greater than or equal to


                            File Operations:

                            -s file exists and is not empty
                            -f file exists and is not a directory
                            -d directory exists
                            -x file is executable
                            -w file is writable
                            -r

                            file is readable

                             


                            نمونه خاص از تطبیق در شل URL

                            [[ $a == z* ]]   # True if $a starts with a "z" (wildcard matching).
                            [[ $a == "z*" ]] # True if $a is equal to z* (literal matching).

                             

                            در تمامی فایل‌های موجود در یک فولدرکلمه IRAN را در کاراکتر شماره شش inject می‌کند:

                            for file in * ;
                            do
                                 mv ./"$file" "${file:0:6}IRAN${file:6}";
                                 done
                            

                            یعنی abcdef.ext  تبدیل می‌شود به abcdefIRAN.ext
                             


                             

                            حذف کاراکتر دَش یا همان «خط تیره» از تمامی فایل ‌های موجود در یک فولدر: 

                             for file in ./*;
                                 do
                                     mv "$file" "${file/-/}";
                                 done
                            

                             

                            • behrooz mohamadi nsasab
                            ۲۴
                            خرداد
                            بادستور زیر می‌توان سرعت خواند و نوشتن از دیسک را فهیمد:
                            echo -e "WRITE:";
                            dd if=/dev/zero of=/tmp/output count=1 bs=100M ;
                            rm -f /tmp/output;
                             echo -e "\nREAD";
                            sudo hdparm -t /dev/sda

                            • behrooz mohamadi nsasab
                            ۲۴
                            خرداد

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

                            taskkill f fi "status eq not responding"

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

                            نصب در کلاینت

                            در سمت کلایت باید سرویس 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
                            $
                            لینک های مفید:

                            LINK


                            • behrooz mohamadi nsasab
                            ۲۴
                            خرداد

                            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.


                            • behrooz mohamadi nsasab
                            ۲۴
                            خرداد

                            در سیستم عامل لینوکس شما قالبیت این را دارید که از محیط گرافیکی دلخواه خود استفاده نمایید: (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




                            • behrooz mohamadi nsasab
                            ۲۲
                            خرداد

                            رفع مشکل 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;

                            • behrooz mohamadi nsasab
                            ۲۲
                            خرداد

                            نکته: سرویس 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;
                                   }
                            }


                            • behrooz mohamadi nsasab
                            ۲۲
                            خرداد

                            برای راه اندازی سرویس 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 حذف کرده و به بلاک های آن دست نمی‌زنیم.

                            • behrooz mohamadi nsasab
                            ۱۹
                            خرداد
                            • 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)
                              
                            • behrooz mohamadi nsasab
                            ۱۹
                            خرداد
                            در لینومس دسترسی کامل با دو روش زیر امکان پذیر است:
                            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







                            • behrooz mohamadi nsasab
                            ۱۶
                            خرداد

                            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;
                            • behrooz mohamadi nsasab
                            ۱۶
                            خرداد

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

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

                            گام دوم: instal this package

                            گام سوم: select opration sysstem

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

                            گام پنجم:

                            sudo apt-get install pycharm-community-sloppy



                            • behrooz mohamadi nsasab
                            ۱۳
                            خرداد
                            اسکرین برای بوجود آوردن چند 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

                            • behrooz mohamadi nsasab
                            ۱۲
                            خرداد

                            افزودن دیسک local برای گرفتن بسته‌ها:

                            برنامه apt-cdrom را نصب کنید و مطابق ریر، مسیر mount point دیسک را اضافه نمایید(همچنین میتوانید keydrive یک USBرا اضافه نمایید).

                            apt-cdrom add directory
                            • behrooz mohamadi nsasab
                            ۱۲
                            خرداد

                            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


                            • behrooz mohamadi nsasab
                            ۰۶
                            خرداد

                            در نرم افزار libreOffice در مجموعه excell آن:

                            f8:                       select+بالا و پایین و چپ و راست
                            f7:                       toolbar
                            f11:                     منوی سمت راست   
                            shift+f6:             toolbar

                            در گنوم:

                             ALT+F1                          برابر است با پنجره
                            shift + F10                        برابر است با راست کلیک
                            ctrl+F10                            برابر است با گزینه های منوی بالای هر پنجره

                            • behrooz mohamadi nsasab
                            ۰۵
                            خرداد

                            جستجو در عبارت است نظیر 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 user

                             

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

                            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
                             

                            نمایش نام هاست

                            hostname

                            با چه یوزری وارد شده  ایم

                            whoami

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

                            tracert IP

                            یافتن مک از روی آی پی. نمایش جدول آی پی و مک آدرس(آی پی های داینامیک)

                            arp -a

                            نمایش جدول آی پی و مک آدرس(آی پی های استاتیک)

                            arp -s

                            پاک کردن همه آی پی های موجود در جدول

                            arp -d

                            پاک کردن یک آی پی خاص از جدول

                            arp -d IP

                            لینک مفید

                            • behrooz mohamadi nsasab
                            ۲۴
                            ارديبهشت
                            مشاهده اطلاعاتی نظیر رم و هارد و سریال پورت و یو اس بی
                            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”  خوانده میشود.
                            • behrooz mohamadi nsasab
                            ۱۰
                            ارديبهشت

                            از طریق دستورات زیر میتوانیدتمامی خروجی شل های یک سرور را مشاهده نمایید:

                            باید دستورات زیر را در آخر bashrc یوزر خود بیافزایید.


                            export PS1="\u@\h[\t] [\w]-[\$?]\$ "

                            if [ "$SHLVL" = 1 ]; then /usr/bin/script   -afq /var/log/Terminal/Terminal_$(date +%Y%m%d-%H%M%S).log;  fi;

                            • behrooz mohamadi nsasab
                            ۱۰
                            ارديبهشت

                            ترتیب خوانده شدن فایل های کانفیگی در  دبیان 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 (اجرا در ششمین مرحله)

                            • behrooz mohamadi nsasab
                            ۱۰
                            ارديبهشت
                            برای تغییر سرخط در لینوکس از دستور زیر در bashrc ویا در profile قرار دهید(لینک):
                            /t   :     time
                            /$? :     exit code
                            /u   :     user
                            \h   :     hostname
                            \$   :     $ or #
                             
                            #color blue:      \[\033[01;34m\]
                            #color purple:   \[\033[01;35m\]
                            #color white:    \[\033[00m\]
                            #color green:    \[\033[01;32m\]
                            #color yellow:  \[\033[33m\]       or    \[\e[1;32m\]
                             
                            PS1="\u@\h[\t] [\w]-[\$?]\$ "
                            behrooz@viratech[14:54:04] [~]-[0]$
                             
                            PS1='${debian_chroot:+($debian_chroot)}\[\033[01;32m\]\u@\h\[\033[00m\]:\[\033[01;34m\][\w]\[\033[01;35m\][\t]\[\033[01;34m\][$?]\[\033[33m\]\$\[\033[00m\] '
                            user@private:[~][11:33:40][0]$
                             
                             
                            txtblk='\e[0;30m' # Black - Regular
                            txtred='\e[0;31m' # Red
                            txtgrn='\e[0;32m' # Green
                            txtylw='\e[0;33m' # Yellow
                            txtblu='\e[0;34m' # Blue
                            txtpur='\e[0;35m' # Purple
                            txtcyn='\e[0;36m' # Cyan
                            txtwht='\e[0;37m' # White
                            bldblk='\e[1;30m' # Black - Bold
                            bldred='\e[1;31m' # Red
                            bldgrn='\e[1;32m' # Green
                            bldylw='\e[1;33m' # Yellow
                            bldblu='\e[1;34m' # Blue
                            bldpur='\e[1;35m' # Purple
                            bldcyn='\e[1;36m' # Cyan
                            bldwht='\e[1;37m' # White
                            unkblk='\e[4;30m' # Black - Underline
                            undred='\e[4;31m' # Red
                            undgrn='\e[4;32m' # Green
                            undylw='\e[4;33m' # Yellow
                            undblu='\e[4;34m' # Blue
                            undpur='\e[4;35m' # Purple
                            undcyn='\e[4;36m' # Cyan
                            undwht='\e[4;37m' # White
                            bakblk='\e[40m'   # Black - Background
                            bakred='\e[41m'   # Red
                            bakgrn='\e[42m'   # Green
                            bakylw='\e[43m'   # Yellow
                            bakblu='\e[44m'   # Blue
                            bakpur='\e[45m'   # Purple
                            bakcyn='\e[46m'   # Cyan
                            bakwht='\e[47m'   # White
                            txtrst='\e[0m'    # Text Reset
                             
                             
                             
                            • behrooz mohamadi nsasab
                            ۰۹
                            ارديبهشت

                            مقایسه میزان رم با استفاده از دو دستور:   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
                            • behrooz mohamadi nsasab
                            ۰۲
                            ارديبهشت
                            باز شدن صفحه network adapter setting در ویندوز
                            ncpa.cpl
                            باز شدن system tools در computer managment در ویندوز
                            sysdm.cpl
                            باز شدن صفحه پاک کردن یک برنامه
                            appwiz.cpl
                            • behrooz mohamadi nsasab
                            ۰۷
                            فروردين
                            برخی دسترسی های خاص در لینوکس وجود دارند که در ادامه همین پست به آنها می‌پردازیم
                            $ touch 970107.txt
                            $ lsattr 970107.txt
                            --------------e---- 970107.txt
                            
                            $ echo salam >> /tmp/970107.txt
                            $ cat  /tmp/970107.txt
                            salam
                            $ sudo chattr +i /tmp/970107.txt
                            $ lsattr 970107.txt
                            ----i---------e---- 970107.txt
                            $ echo salam2 >> /tmp/970107.txt
                            bash: /tmp/970107.txt: Operation not permitted
                            $ sudo rm -rf  /tmp/970107.txt
                            rm: cannot remove '/tmp/970107.txt': Operation not permitted
                            $ sudo mv   /tmp/970107.txt  ~
                            mv: cannot move '/tmp/970107.txt' to '/home/behrooz/970107.txt': Operation not permitted
                            $ sudo chattr -i /tmp/970107.txt
                            $ lsattr /tmp/970107.txt
                            --------------e---- /tmp/970107.txt

                            • behrooz mohamadi nsasab
                            ۰۷
                            فروردين
                            برای ساختن یک فایل سیستم از نوع NTFS از دستور زیر استفاده نمایید
                            mkntfs -Q -v -F -L “” /dev/sdb1
                            برای ساختن یک فایل سیستم از نوع EXT4 از دستور زیر استفاده نمایید
                            mkfs.ext4 -F -L “” /dev/sdb1
                            برای ساختن یک فایل سیستم از نوع FAT32 از دستور زیر استفاده نمایید
                            mkfs.fat -F32 -v -I -n " " /dev/sdb1
                            چک فایل سیستم و فیکس شدن ارورهای موجود(اگر اروری موجود باشد)
                            e2fsck -f -y -v -C 0 /dev/sdb1
                            shirink کردن (کوچک کردن حجم)
                            Shrink /dev/sdb1 from 7.50 GiB to 6.01 GiB : resize2fs -p /dev/sdb1 6306816K
                            grow کردن (بزرگ کردن حجم)
                            Grow  /dev/sdb1 from 1.39 GiB to 7.50 GiB :  resize2fs -p /dev/sdb1

                            • behrooz mohamadi nsasab
                            ۰۶
                            فروردين

                            فهمیدن مک یک آی پی :

                            ./VMware.bundle -u"vmware-workstation"

                            نمایش مک‌آدرس‌ها

                            sudo arp -a
                            اسکن مک آدرس یک آی پی
                            sudo arp-scan 192.168.1.0/24

                            نمایش اطلاعات بسته ها:

                            dpkg -l
                            بررسی وجود یک ریشه در لینوکس:
                            test -d /home/zabbix || mkdir /home/zabbix

                            فهمیدن اینکه سرور فعلی vm هست یا سرور فیزیکی هست:

                             
                            dmidecode -t system
                             
                            $printf '\033[;H'            #Move text pointer at first line
                            • behrooz mohamadi nsasab
                            ۰۵
                            فروردين
                            CentOS:            sudo yum install git
                            Debian/Ubuntu: sudo apt-get install git
                            sudo git clone https://github.com/letsencrypt/letsencrypt /opt/letsencrypt
                            cd /opt/letsencrypt
                            sudo -H ./letsencrypt-auto certonly --standalone -d example.com -d www.example.com
                            نکته: برای هر دامنه ای که نیاز به داشتن ca است از سوییچ d استفاده شده و سپس نام آن درج شود
                            نکته: برای این که دستور بالا به درستی کار کند Nginx را پایین بیاورید.
                            -------------------------------------------------------------------------------
                            Please read the Terms of Service at
                            https://letsencrypt.org/documents/LE-SA-v1.2-November-15-2017.pdf. You must
                            agree in order to register with the ACME server at
                            https://acme-v01.api.letsencrypt.org/directory
                            -------------------------------------------------------------------------------
                            (A)gree/(C)ancel: a
                            
                            -------------------------------------------------------------------------------
                            Would you be willing to share your email address with the Electronic Frontier
                            Foundation, a founding partner of the Let's Encrypt project and the non-profit
                            organization that develops Certbot? We'd like to send you email about EFF and
                            our work to encrypt the web, protect its users and defend digital rights.
                            -------------------------------------------------------------------------------
                            (Y)es/(N)o: n
                            در بالا لایسنس را می‌پذیریم:
                            سپس n  را وارد میکنیم
                            در ادامه اگر کار به درستی تمام شده باشد باید پیامی مشابه زیر نمایش شود(Congratulations):
                            IMPORTANT NOTES:
                             - Congratulations! Your certificate and chain have been saved at:
                               /etc/letsencrypt/live/example.com/fullchain.pem
                               Your key file has been saved at:
                               /etc/letsencrypt/live/example.com/privkey.pem
                               Your cert will expire on 2018-05-27. To obtain a new or tweaked
                               version of this certificate in the future, simply run
                               letsencrypt-auto again. To non-interactively renew *all* of your
                               certificates, run "letsencrypt-auto renew"
                             - If you like Certbot, please consider supporting our work by:
                               Donating to ISRG / Let's Encrypt:   https://letsencrypt.org/donate
                               Donating to EFF:                    https://eff.org/donate-le
                            نکته: certificate ها در مسیر زیر ذخیره می شوند:
                            sudo ls /etc/letsencrypt/live
                            با دستور زی رمسیر فایل و کلید certificate را مشاهده خواهید کرد:

                            ./certbot-auto certificates
                            Found the following certs:
                            Certificate Name: example.com
                            Domains: example.com www.example.com
                            Expiry Date: 2018-05-27 20:49:02+00:00 (VALID: 89 days)
                            Certificate Path: /etc/letsencrypt/live/example.com/fullchain.pem
                            Private Key Path: /etc/letsencrypt/live/example.com/privkey.pem

                            لینک های مفید: URL

                             لینک مفید : URL







                            • behrooz mohamadi nsasab
                            ۰۵
                            فروردين
                            برنامه at به برنامه زمانبندی (schedule) در لینوکس است که برای استفاده از آن باید این برنامه را نصب نماییم
                            sudo apt-get install at
                            برای شروع به کار(اعلام زمان اجرای یک تسک) دستور زیر را وارد میکنیم:

                            at 09:01 AM 07/20/2018
                            سپس وارد محیطی میشویم که باید در آن دستورات تسک را وارد نماییم.سپس ctrl+D را می‌زنیم و از محیط دستورات خارج می‌شویم

                            مثلا اگر دستور زیر یک ایمیل ارسال می‌کند:
                            echo "TEXTBODY" | mail -s "SUBJECT"MailAddress1 MailAddress2 MailAddress3
                            آنگاه اگر یخواهیم در زمان 20181225 ایمیلی ارسال بشود از روش زیر اقدام میکنیم:
                            behrooz@Home:~$  at 09:01 AM 12/25/2018
                            > echo "یادآوری" | mail -s "عنوان" mohamadinasab@viratech.ir behroozmohammadinasab@gmail.com
                            ctrl+D
                            behrooz@Home:~$
                            لینک مفید:  URL

                            • behrooz mohamadi nsasab
                            ۰۵
                            فروردين
                            فهمیدن IP از نوع Public‌:
                            alias B_ipPublic='echo -e "192.168.2.203===>$(curl --interface 192.168.2.203 -s http://ip.jsontest.com|jq .ip |tr -d "\"")'  #dependency: jq, curl
                            alias B_ipPublic='curl -s ifconfig.me'
                            دریافت آی پی یک اینرفیس(آی پی لوکالی):
                            alias B_ipPrivate='ip addr list dev eth0'
                            اس اس اچ به یک آدرس:

                            alias ssh_LfreeNas='sshpass -p PASSWORD ssh USER@IP'    #dependency: sshpass

                            دیوایس های متصل به سیستم

                            alias B_mount="mount | column -t"

                            پاک کردن با تایید اگر بیش از سه فایل داریم پاک می‌کنیم(do not delete / or prompt if deleting more than 3 files at a time)


                            alias rm='rm -I --preserve-root'

                            جلوگیری از این که در مسیر اصلی / تغییری (بصورت بازگشتی) انجام دهیم

                            alias chown='chown --preserve-root'    # Parenting changing perms on /
                            alias chmod='chmod --preserve-root'    # Parenting changing perms on /
                            alias chgrp='chgrp --preserve-root'       # Parenting changing perms on /

                            بازگشت به مسیر بالاتر:


                            alias ..='cd ..'

                            alias ...='cd ../..'

                            alias ....='cd ../../..'

                            جستجوی یک پردازه در لبست تمامی پردازه‌ها (نیاز به آرگومان ورودی که آن را جستجو نماید)

                            alias ps?="ps aux | grep"

                            تولید پسورد رندم:

                            alias B_genPasswd="strings /dev/urandom | grep -o '[[:alnum:]]' | head -n 30 | tr -d '\n'; echo"

                            نمایش صفحه نمایش بصورت جالب(funny)

                            alias B_busy="cat /dev/urandom | hexdump -C | grep \"ca fe\""

                            مشاهده لاگ

                            alias B_logDmesg='sudo dmesg -Tx  --follow'

                            alias B_logSyslog='sudo tail -n 25 -f /var/log/syslog'

                            گرفتن تایید:

                            alias mv='mv -i'
                            alias cp='cp -i'
                            alias ln='ln -i'

                            الیاس‌ های رایج:

                            alias ls="ls --color=auto"

                            alias ll="ls --color -al"

                            alias grep='grep --color=auto'

                            چند تابع کاربردی که میتوان بعنوان الیاس از آن استفاده کرد:

                            mcd() { mkdir -p "$1"; cd "$1";}

                            cls() { cd "$1"; ls;}

                            B_backup () { _time=$(date +%Y%m%d-%H%M%S) ;  cp "$1"{,.bak_$_time}; }


                            نکته : alias های زیر از سایت URL برگرفته شده است و هیچ ضمانتی برای اجرای آن نیست:

                            extract() { 
                                if [ -f $1 ] ; then 
                                  case $1 in 
                                    *.tar.bz2)   tar xjf $1     ;; 
                                    *.tar.gz)    tar xzf $1     ;; 
                                    *.bz2)       bunzip2 $1     ;; 
                                    *.rar)       unrar e $1     ;; 
                                    *.gz)        gunzip $1      ;; 
                                    *.tar)       tar xf $1      ;; 
                                    *.tbz2)      tar xjf $1     ;; 
                                    *.tgz)       tar xzf $1     ;; 
                                    *.zip)       unzip $1       ;; 
                                    *.Z)         uncompress $1  ;; 
                                    *.7z)        7z x $1        ;; 
                                    *)     echo "'$1' cannot be extracted via extract()" ;; 
                                     esac 
                                 else 
                                     echo "'$1' is not a valid file" 
                                 fi 
                            } 
                             
                            #System info 
                            alias tree="ls -R | grep ":$" | sed -e 's/:$//' -e 's/[^-][^\/]*\//--/g' -e 's/^/   /' -e 's/-/|/'" 
                            sbs(){ du -b --max-depth 1 | sort -nr | perl -pe 's{([0-9]+)}{sprintf "%.1f%s", $1>=2**30? ($1/2**30, "G"): $1>=2**20? ($1/2**20, "M"): $1>=2**10? ($1/2**10, "K"): ($1, "")}e';} 
                            alias intercept="sudo strace -ff -e trace=write -e write=1,2 -p" 
                            alias meminfo='free -m -l -t' 
                            alias volume="amixer get Master | sed '1,4 d' | cut -d [ -f 2 | cut -d ] -f 1" 
                             
                            #Network 
                            alias websiteget="wget --random-wait -r -p -e robots=off -U mozilla" 
                            alias listen="lsof -P -i -n" 
                            alias port='netstat -tulanp'
                            gmail() { curl -u "$1" --silent "https://mail.google.com/mail/feed/atom" | sed -e 's/<\/fullcount.*/\n/' | sed -e 's/.*fullcount>//'}
                            alias ipinfo="curl ifconfig.me && curl ifconfig.me/host" 
                            getlocation() { lynx -dump http://www.ip-adress.com/ip_tracer/?QRY=$1|grep address|egrep 'city|state|country'|awk '{print $3,$4,$5,$6,$7,$8}'|sed 's\ip address flag \\'|sed 's\My\\';} 
                             
                            #Funny 
                            kernelgraph() { lsmod | perl -e 'print "digraph \"lsmod\" {";<>;while(<>){@_=split/\s+/; print "\"$_[0]\" -> \"$_\"\n" for split/,/,$_[3]}print "}"' | dot -Tpng | display -;} 
                            
                            • behrooz mohamadi nsasab
                            ۰۵
                            فروردين

                            برنامه ufw فایروالی است که به حالت سرویس به اجرا درآمده و بسته های ورودی و خروجی را فیلتر می‌نماید.

                            استفاده از آی پی ورژن6

                            # sudo vim /etc/default/ufw

                            IPV6=yes

                            فعال‌ سازی/غیرفعال سازی

                            # sudo ufw enable/disable

                            بررسی وضعیت موجود

                            # sudo ufw status

                            # sudo ufw status numbered

                            بررسی وضعیت موجود(جزییات بیشتر)

                            # sudo ufw status verbose

                            نمایش رول‌ها

                            # sudo ufw status numbered
                            Numbered Output:
                            Status: active To Action From
                            -- ------ ----
                            [1] 22 ALLOW IN 15.15.15.0/24
                            [2] 80 ALLOW IN Anywhere

                            حذف رول‌های موجود(شماره [2 ])

                            # sudo ufw delete 2

                            # sudo ufw delete allow http

                            # sudo ufw delete allow 80

                            تغییر در پالیسی پیش‌فرض ورودی یا خروجی

                            # sudo ufw default deny incoming

                            # sudo ufw default allow outgoing

                            بازگشت به حالت اولیه-فایروال غیرفعال گشته و قوانین حذف خواهند شد (نکته پالیسی‌های پیشفرض ورودی و خروجی تغییر نخواهد کرد)

                            # sudo ufw reset

                            باز بودن تمام دسترسی از یک آدرس آی پی خاص

                            # sudo ufw allow from 15.15.15.51
                            باز شدن یک دامنه(از 15.15.15.1 تا 15.15.15.254)
                            # sudo ufw allow from 15.15.15.0/24

                            باز شدن دسترسی از هاست 15.15.15.51 به پورت 22 سرور

                            # sudo ufw allow from 15.15.15.51    to any port 22
                            باز شدن دسترسی از یک دامنه به پورت 22 سرور
                            # sudo ufw allow from 15.15.15.0/24 to any port 22
                            باز شدن پورت 80 برای همه آی‌پی‌ها در اینترفیس etj0
                            # sudo ufw allow in on eth0 to any port 80

                            باز کردن یک پورت

                            # sudo ufw allow PORT

                            # sudo ufw allow PORT/tcp

                            باز کردن یک بازه پورت

                            # sudo ufw allow 6000:6007/tcp

                            باز شدن پورت ssh

                            # sudo ufw allow ssh

                            # sudo ufw allow 22

                            بسته شدن پورت پروتکل اف تی پی

                            # sudo ufw allow ftp

                            ریست تمام رول‌ها  به حالت اولیه:

                            # sudo ufw reset

                             

                            UFW

                            • behrooz mohamadi nsasab
                            ۱۴
                            اسفند

                            1-cat /proc/cpuinfo

                            processor	: 0
                            vendor_id	: GenuineIntel
                            cpu family	: 6
                            model		: 69
                            model name	: Intel(R) Core(TM) i5-4210U CPU @ 1.70GHz
                            stepping	: 1
                            microcode	: 0x1c
                            cpu MHz		: 1700.062
                            cache size	: 3072 KB
                            physical id	: 0
                            siblings	: 4
                            core id		: 0
                            cpu cores	: 2
                            apicid		: 0
                            initial apicid	: 0
                            fpu		: yes
                            fpu_exception	: yes
                            cpuid level	: 13
                            wp		: yes
                            flags		: fpu vme de pse tsc msr pae mce cx8 apic sep mtrr pge mca cmov pat pse36 clflush dts acpi mmx fxsr sse sse2 ss ht tm pbe syscall nx pdpe1gb rdtscp lm constant_tsc arch_perfmon pebs bts rep_good nopl xtopology nonstop_tsc aperfmperf eagerfpu pni pclmulqdq dtes64 monitor ds_cpl vmx est tm2 ssse3 sdbg fma cx16 xtpr pdcm pcid sse4_1 sse4_2 movbe popcnt tsc_deadline_timer aes xsave avx f16c rdrand lahf_lm abm epb tpr_shadow vnmi flexpriority ept vpid fsgsbase tsc_adjust bmi1 avx2 smep bmi2 erms invpcid xsaveopt dtherm ida arat pln pts
                            bugs		:
                            bogomips	: 4788.92
                            clflush size	: 64
                            cache_alignment	: 64
                            address sizes	: 39 bits physical, 48 bits virtual
                            power management:
                            ......

                            2- lscpu

                            Architecture:          x86_64
                            CPU op-mode(s):        32-bit, 64-bit
                            Byte Order:            Little Endian
                            CPU(s):                4
                            On-line CPU(s) list:   0-3
                            Thread(s) per core:    2
                            Core(s) per socket:    2
                            Socket(s):             1
                            NUMA node(s):          1
                            Vendor ID:             GenuineIntel
                            CPU family:            6
                            Model:                 69
                            Model name:            Intel(R) Core(TM) i5-4210U CPU @ 1.70GHz
                            Stepping:              1
                            CPU MHz:               1303.687
                            CPU max MHz:           2700.0000
                            CPU min MHz:           800.0000
                            BogoMIPS:              4788.92
                            Virtualization:        VT-x
                            L1d cache:             32K
                            L1i cache:             32K
                            L2 cache:              256K
                            L3 cache:              3072K
                            NUMA node0 CPU(s):     0-3
                            Flags:                 fpu vme de pse tsc msr pae mce cx8 apic sep mtrr pge mca cmov pat pse36 clflush dts acpi mmx fxsr sse sse2 ss ht tm pbe syscall nx pdpe1gb rdtscp lm constant_tsc arch_perfmon pebs bts rep_good nopl xtopology nonstop_tsc aperfmperf eagerfpu pni pclmulqdq dtes64 monitor ds_cpl vmx est tm2 ssse3 sdbg fma cx16 xtpr pdcm pcid sse4_1 sse4_2 movbe popcnt tsc_deadline_timer aes xsave avx f16c rdrand lahf_lm abm epb tpr_shadow vnmi flexpriority ept vpid fsgsbase tsc_adjust bmi1 avx2 smep bmi2 erms invpcid xsaveopt dtherm ida arat pln pts
                            

                            3- cpuid

                            CPU 0:
                            vendor_id = "GenuineIntel"
                            version information (1/eax):
                            processor type  = primary processor (0)
                            family          = Intel Pentium Pro/II/III/Celeron/Core/Core 2/Atom, AMD Athlon/Duron, Cyrix M2, VIA C3 (6)
                            model           = 0x5 (5)
                            stepping id     = 0x1 (1)
                            extended family = 0x0 (0)
                            extended model  = 0x4 (4)
                            (simple synth)  = Intel Mobile Core i3-4000Y / Mobile Core i5-4000Y / Mobile Core i7-4000Y / Mobile Pentium 3500U/3600U/3500Y / Mobile Celeron 2900U (Mobile U/Y) (Haswell), 22nm
                            miscellaneous (1/ebx):
                            process local APIC physical ID = 0x0 (0)
                            cpu count                      = 0x10 (16)
                            CLFLUSH line size              = 0x8 (8)
                            brand index                    = 0x0 (0)
                            brand id = 0x00 (0): unknown
                            feature information (1/edx):
                            x87 FPU on chip                        = true
                            virtual-8086 mode enhancement          = true
                            debugging extensions                   = true
                            page size extensions                   = true
                            time stamp counter                     = true
                            RDMSR and WRMSR support                = true
                            physical address extensions            = true
                            ....

                            4- sudo dmidecode --type processor

                            # dmidecode 3.0
                            Getting SMBIOS data from sysfs.
                            SMBIOS 2.7 present.
                            Handle 0x0004, DMI type 4, 42 bytes
                            Processor Information
                            Socket Designation: U3E1
                            Type: Central Processor
                            Family: Core i5
                            Manufacturer: Intel(R) Corporation
                            ID: 51 06 04 00 FF FB EB BF
                            Signature: Type 0, Family 6, Model 69, Stepping 1
                            Flags:
                            FPU (Floating-point unit on-chip)
                            VME (Virtual mode extension)
                            DE (Debugging extension)
                            PSE (Page size extension)
                            TSC (Time stamp counter)
                            MSR (Model specific registers)
                            PAE (Physical address extension)
                            MCE (Machine check exception)
                            CX8 (CMPXCHG8 instruction supported)
                            APIC (On-chip APIC hardware supported)
                            SEP (Fast system call)
                            MTRR (Memory type range registers)
                            PGE (Page global enable)
                            MCA (Machine check architecture)
                            .....

                            5- inxi -C

                            CPU:       Dual core Intel Core i5-4210U (-HT-MCP-) cache: 3072 KB 
                            clock speeds: max: 2700 MHz 1: 1958 MHz 2: 1993 MHz 3: 1775 MHz 4: 1714 MHz
                            

                            6- sudo lshw -C CPU

                            *-cpu                   
                            description: CPU
                            product: Intel(R) Core(TM) i5-4210U CPU @ 1.70GHz
                            vendor: Intel Corp.
                            physical id: 4
                            bus info: cpu@0
                            version: Intel(R) Core(TM) i5-4210U CPU @ 1.70GHz
                            serial: To Be Filled By O.E.M.
                            slot: U3E1
                            size: 2626MHz
                            capacity: 2700MHz
                            width: 64 bits
                            clock: 100MHz
                            capabilities: x86-64 fpu fpu_exception wp vme de pse tsc msr pae mce cx8 apic sep mtrr pge mca cmov pat pse36 clflush dts acpi mmx fxsr sse sse2 ss ht tm pbe syscall nx pdpe1gb rdtscp constant_tsc arch_perfmon pebs bts rep_good nopl xtopology nonstop_tsc aperfmperf eagerfpu pni pclmulqdq dtes64 monitor ds_cpl vmx est tm2 ssse3 sdbg fma cx16 xtpr pdcm pcid sse4_1 sse4_2 movbe popcnt tsc_deadline_timer aes xsave avx f16c rdrand lahf_lm abm epb tpr_shadow vnmi flexpriority ept vpid fsgsbase tsc_adjust bmi1 avx2 smep bmi2 erms invpcid xsaveopt dtherm ida arat pln pts cpufreq
                            configuration: cores=2 enabledcores=2 threads=4

                            7- hardinfo

                            8- hwinfo --cpu

                            01: None 00.0: 10103 CPU                                        
                            [Created at cpu.460]
                            Unique ID: rdCR.j8NaKXDZtZ6
                            Hardware Class: cpu
                            Arch: X86-64
                            Vendor: "GenuineIntel"
                            Model: 6.69.1 "Intel(R) Core(TM) i5-4210U CPU @ 1.70GHz"
                            Features: fpu,vme,de,pse,tsc,msr,pae,mce,cx8,apic,sep,mtrr,pge,mca,cmov,pat,pse36,clflush,dts,acpi,mmx,fxsr,sse,sse2,ss,ht,tm,pbe,syscall,nx,pdpe1gb,rdtscp,lm,constant_tsc,arch_perfmon,pebs,bts,rep_good,nopl,xtopology,nonstop_tsc,aperfmperf,eagerfpu,pni,pclmulqdq,dtes64,monitor,ds_cpl,vmx,est,tm2,ssse3,sdbg,fma,cx16,xtpr,pdcm,pcid,sse4_1,sse4_2,movbe,popcnt,tsc_deadline_timer,aes,xsave,avx,f16c,rdrand,lahf_lm,abm,epb,tpr_shadow,vnmi,flexpriority,ept,vpid,fsgsbase,tsc_adjust,bmi1,avx2,smep,bmi2,erms,invpcid,xsaveopt,dtherm,ida,arat,pln,pts
                            Clock: 2080 MHz
                            BogoMips: 4788.92
                            Cache: 3072 kb
                            Units/Processor: 16
                            Config Status: cfg=new, avail=yes, need=no, active=unknown
                            ....

                            9-nproc

                            10-lspci




                            • behrooz mohamadi nsasab
                            ۰۸
                            اسفند

                            1- sudo apt-get install gnome-panel gnome-settings-daemon metacity nautilus gnome-terminal
                            2- sudo apt-get install vnc4server
                            3- vncserver
                            4- vncserver -kill :1
                            5- vim ~/.vnc/xstartup 
                            change:
                             
                            #!/bin/sh
                            export XKL_XMODMAP_DISABLE=1
                            unset SESSION_MANAGER
                            unset DBUS_SESSION_BUS_ADDRESS
                            [ -x /etc/vnc/xstartup ] && exec /etc/vnc/xstartup
                            [ -r $HOME/.Xresources ] && xrdb $HOME/.Xresources
                            xsetroot -solid grey
                            vncconfig -iconic &
                             
                            gnome-panel &
                            gnome-settings-daemon &
                            metacity &
                            nautilus &
                            gnome-terminal &
                             
                             
                            6- vncserver

                            • behrooz mohamadi nsasab
                            ۰۸
                            اسفند


                            1- sudo apt-get install mate-desktop-environment
                            2- sudo apt-get install vnc4server
                            3- vncserver
                            4- vncserver -kill :1
                            5- vim ~/.vnc/xstartup 
                            change:
                             
                            #!/bin/bash
                            unset SESSION_MANAGER
                            unset DBUS_SESSION_BUS_ADDRESS
                            #. /etc/X11/xinit/xinitrc
                            /usr/bin/mate-session
                             
                            [ -x /etc/vnc/xstartup ] && exec /etc/vnc/xstartup
                            [ -r $HOME/.Xresources ] && xrdb $HOME/.Xresources
                            xsetroot -solid grey
                            vncconfig -iconic &
                            x-terminal-emulator -geometry 80x24+10+10 -ls -title "$VNCDESKTOP Desktop" &
                             
                            **only debain 9
                            6- sudo vim /etc/vnc.conf
                            add:
                            $localhost = "no";
                              
                            7- vncserver

                            • behrooz mohamadi nsasab
                            ۰۳
                            اسفند

                            Write speed benchmark:    dd if=/dev/zero of=/tmp/output count=1 bs=100M ;rm -f /tmp/output

                            READ speed benchmark: sudo hdparm -t /dev/sda

                            • behrooz mohamadi nsasab
                            ۰۳
                            اسفند
                            در این آموزش می‌خواهیم هارد سرور 192.168.200.3 را به کلاینت 192.168.200.2 بعنوان پارتیشن لوکالی معرفی نماییم.
                            نیازمندی:
                            در سرور: نصب بسته  nfs-kernel-server
                            در کلاینت :‌نصب بسته  nfs-common

                            در سرور (192.168.200.3):
                            1-$ sudo apt-get update
                            2-$ sudo apt-get install nfs-common
                            3- create one DIRECTORY to share
                            4- sudo chown nobody:nogroup DIRECTORY
                            5- sudo nano /etc/exports
                            6- DIRECTORY       192.168.200.2(rw,sync,no_root_squash,no_subtree_check)
                            directory_to_share       client(share_option1,...,share_optionN)
                            7- sudo exportfs -a
                            8- sudo service nfs-kernel-server start



                            در کلاینت (192.168.200.2)
                            1- sudo apt-get update
                            2- sudo apt-get install nfs-common
                            3-create MountPoint
                            4- sudo mount 192.168.200.3:DIRECTORY    #Directory on server 192.168.200.3
                            5- df -h
                            6- sudo mount -a
                            for permanently mount:
                            7-vim /etc/fstab
                            8- 192.168.200.3:DIRECTORY    MountPoint   nfs auto,noatime,nolock,bg,nfsvers=4,intr,tcp,actimeo=1800 0 0

                            LINK
                            • behrooz mohamadi nsasab
                            ۲۸
                            بهمن

                            گذاشتن کامنت در اول چندین خط به صورت همزمان

                            ابتدا یک فایل متنی را در برنامه vim  باز نمایید
                            در ابتدای محدوده  ctrl+v  را بزنید و سپس محدوده را مشخص نمایید و سپس دکمه  Shift+I را بزنید تا به حالت insert mode بروید -در حالت insert mode کاراکتر # را در ابتدای محدوده تایپ کنیدو سپس ESC را بزنید-هم اکنون کل محدوده تبدیل به کامنت شده است


                            نکته: با کاراکتر e به انتهای کلمه خواهید رفت

                            نکته: با de کلمه جاری را پاک خواهید کرد

                            • behrooz mohamadi nsasab
                            ۲۷
                            بهمن

                            در حین نصب ویندوز اگر کلید F10 را به همراه Shift بزنید، پنجره مشکی رنگ CMD باز خواهد شد و در آن میتوانید فعالیت نمایید

                            • behrooz mohamadi nsasab
                            ۲۲
                            بهمن

                            1-IP(OnBoot-Permanent)-dhcp-debian

                             

                              vim /etc/network/interfaces
                              • auto eth0
                              • iface eth0 inet dhcp
                              sudo /etc/init.d/networking restart

                                 

                                2-IP(OnBoot-Permanent)-static-debian

                                 

                                  vim /etc/network/interfaces
                                  • auto eth0
                                  • iface eth0 inet static
                                  • address 192.168.50.2
                                  • netmask 255.255.255.0
                                  • gateway 192.168.50.1
                                  • dns-nameservers 192.168.200.1
                                  sudo /etc/init.d/networking restart

                                     

                                    3-IP(OnBoot-Permanent)-dhcp-redhat

                                     

                                     

                                      vim /etc/sysconfig/network-scripts/ifcfg-eth0
                                      • DEVICE=eth0
                                      • TYPE=Ethernet
                                      • ONBOOT=yes
                                      • BOOTPROTO=dhcp
                                      • IPV4_FAILURE_FATAL=yes
                                      • NAME="System eth0"

                                      service network restart

                                      or

                                      nmcli dev disconnect ${device}
                                      nmcli con reload ${device}
                                      nmcli con up ${device}

                                      4-IP(OnBoot-Permanent)-static-redhat

                                       

                                        vim /etc/sysconfig/network-scripts/ifcfg-eth0
                                        • DEVICE="eth0"
                                        • BOOTPROTO=static
                                        • ONBOOT=yes
                                        • TYPE="Ethernet"
                                        • IPADDR=192.168.50.2
                                        •  NAME="System eth0"
                                        •  HWADDR=00:0C:29:28:FD:4C
                                        • GATEWAY=192.168.50.1
                                        • [PEERDNS=no  (then add DNS to /etc/resolv.conf)]
                                        •  or [DNS1=8.8.8.8] and 
                                        • [DNS2=8.8.4.4]]

                                        service network restart

                                        or

                                        nmcli dev disconnect ${device}
                                        nmcli con reload ${device}
                                        nmcli con up ${device}

                                        5-VirtualIP-(OnBoot-Permanent)-debian-static

                                         

                                          vim /etc/network/interfaces [append]
                                          • iface eth0:0 inet static
                                          • address 123.123.22.22
                                          • netmask 255.0.0.0
                                          • broadcast 123.255.255.255
                                          /etc/init.d/networking restart

                                             

                                             

                                            6-VirtualIP-(OnBoot-Permanent)-debian-DHCP

                                              vim /etc/network/interfaces [append]
                                              • iface eth0:0 inet dhcp
                                              /etc/init.d/networking restart

                                                 

                                                7-virtualIP-(OnBoot-Permanent)-Redhat-static

                                                 

                                                  vim  /etc/sysconfig/network-scripts/ifcfg-eth0:0
                                                  • DEVICE=eth0:0
                                                  • IPADDR=123.123.22.22
                                                  • NETMASK=255.0.0.0
                                                  • NETWORK=123.0.0.0
                                                  • BROADCAST=123.255.255.255
                                                  • ONBOOT=yes

                                                  service network restart

                                                  or

                                                  nmcli dev disconnect ${device}
                                                  nmcli con reload ${device}
                                                  nmcli con up ${device}

                                                   

                                                  8-virtualIP-(OnBoot-permanent)-Redhat-DHCP

                                                   

                                                    vim  /etc/sysconfig/network-scripts/ifcfg-eth0:0
                                                    • DEVICE=eth0:0
                                                    • BOOTPROTO=dhcp
                                                    • ONBOOT=yes

                                                    service network restart

                                                    or

                                                    nmcli dev disconnect ${device}
                                                    nmcli con reload ${device}
                                                    nmcli con up ${device}

                                                     

                                                    9-IP(Not permanent)-ifconfig

                                                    • ifconfig -a                                                               #show all Interface and details
                                                    • ifconfig enp6s0 down                                            #set off interface
                                                    • ifconfig enp6s0 up                                                 #set on interface
                                                    • ifconfig enp6s0 192.168.2.24                                #set ip to interface
                                                    • ifconfig enp6s0 netmask 255.255.255.0                #set subnetmask
                                                    • ifconfig enp6s0 mtu 9000                                      #set mtu
                                                    • ifconfig enp6s0:0 192.168.2.25                             #set secondary ip (virtual)
                                                    • ifconfig eth0:0 down                                              #set off virtual ip
                                                    •  

                                                     

                                                    10-IP(Not permanent)-ip

                                                    • ip a                                                                         #show all Interface and details
                                                    • ip link set eth0 down                                             #set Off interface
                                                    • ip link set eth0 up                                                  #set on interface
                                                    • ip addr add 192.168.2.24/24 dev eth0                    #set ip to interface
                                                    • ip link set eth0 mtu 9000                                       #set mtu
                                                    • ip addr del 192.168.1.1/24 dev eth0                       #set Off interface
                                                    • ip addr show eth0
                                                     
                                                     
                                                     

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

                                                    system-config-network-tui
                                                    نکتنه: میتوانیم با دستور زیر برنامه‌ای در CentOS6 نصب کنیم تا بتوانیم توسط آن کارت شبکه را تنظیم نماییم:
                                                    yum intall system-config-network
                                                    • behrooz mohamadi nsasab
                                                    ۲۲
                                                    بهمن
                                                    می‌توان آدرس مک(یا همان physical address) یک اینتر فیس را تغییر داد
                                                    ifconfig eth0 hw ether AA:BB:CC:DD:EE:FF

                                                    • behrooz mohamadi nsasab
                                                    ۱۶
                                                    بهمن

                                                    sudo nmblookup -A  IP | grep '<00' | grep -v GROUP | awk '{print $1}'

                                                    • behrooz mohamadi nsasab
                                                    ۱۶
                                                    بهمن

                                                    با دستور زیر میتوان کلمات را درون فایل جایگزین نماید

                                                    sudo sed -i 's/OLD/NEW/g' FILENAME

                                                    عبارت اول  یا عبارت دوم:

                                                    sudo sed -i 's/OLD|accent/NEW/g' FILENAME

                                                    حذف کاراکترهای اضافی مخفی (نظیر برنامه dos2unix)

                                                    # sed -i 's/\r//' myfile.txt

                                                    گرفتن بک آپ و بعد تغییر در فایل(بادستور زیر یک فایل با پسوند orig میسازد و سپس تغییرات را انجام میدهد-در این حالت دو فایل داریم)

                                                    sed -i'.orig' 's/this/that/gi' myfile.txt

                                                    نمای خطی که در آن کلمه   word آمده باشد

                                                    sed -n '/WORD/p'

                                                    تبدیل چند تا اسپیس به یک اسپیس در متن

                                                    sed -e 's/  */ /g' فایل

                                                    حذف خطی که در آن کلمه word  یافت شود(i  برای این است که در فایل تغییر کند-اگر نباشد تغییر در فایل رخ نداده و فقط در خروجی مشاهده خواهد شد)

                                                    sed -i '/WORD/d' فایل

                                                    پاک کردن خط اول

                                                    sed '1d' test

                                                    • $ sed '3d' file #Delete 3rd line 
                                                    • $ sed '$d' file #Delete the last line
                                                    • $ sed '2,4d' file # Delete a range of lines(from 2nd line till 4th line)
                                                    • $ sed '2,4!d' file #Delete lines other than the specified range, line other than 2nd till 4th here-پاک کردن همه خطوط بجز خطوط ذکر شده
                                                    • $ sed '1d;$d' file #Delete the first line AND the last line of a file
                                                    • $ sed '/^L/d' file #Delete all lines beginning with a particular character: 'L'  
                                                    • $ sed '/x$/d' file #Delete all lines ending with a particular character, 'x' حرف مورد نظر
                                                    • $ sed '/[xX]$/d' file #Delete all lines ending with either x or X,  i.e case-insensitive delete
                                                    • $ sed '/^$/d' file #Delete all blank lines in the file
                                                    • $ sed '/^ *$/d' file #Delete all lines which are empty or which contains just some blank spaces
                                                    • $ sed '/^[A-Z]*$/d' file #Delete all lines which are entirely in capital letters:
                                                    • $ sed '/Unix/d' file # Delete the lines containing the pattern 'Unix'
                                                    • $ sed '/Unix/!d' file #Delete the lines NOT containing the pattern 'Unix'
                                                    • $ sed '/Unix\|Linux/d' file #Delete the lines containing the pattern 'Unix' OR 'Linux'
                                                    • $ sed '1,/Linux/d' file #Delete the lines starting from the 1st line till encountering the pattern 'Linux'
                                                    • $ sed '/Linux/,$d' file # Delete the lines starting from the pattern 'Linux' till the last line
                                                    • $ sed '${/AIX/d;}' file #Delete the last line ONLY if it contains the pattern 'AIX'
                                                    • $ sed '${/AIX\|HPUX/d;}' file #Delete the last line ONLY if it contains either the pattern 'AIX' or 'HPUX'
                                                    • $ sed '1,4{/Solaris/d;}' file #Delete the lines containing the pattern 'Solaris' only if it is present in the lines from 1 to 4
                                                    • $ sed '/Unix/{N;d;}' file #Delete the line containing the pattern 'Unix' and also the next line
                                                    • $ sed '/Unix/{N;s/\n.*//;}' file #Delete only the next line containing the pattern 'Unix', not the very line
                                                    • $ sed -n '/Linux/{s/.*//;x;d;};x;p;${x;p;}' file | sed '/^$/d' #Delete the line containing the pattern 'Linux', also the line before the pattern
                                                    • $  sed -n '/Linux/{x;d;};1h;1!{x;p;};${x;p;}' file #Delete only the line prior to the line containing the pattern  'Linux', not the very line
                                                    • $ sed -n '/Linux/{N;s/.*//;x;d;};x;p;${x;p;}' file | sed '/^$/d' #Delete the line containing the pattern 'Linux', the line before, the line after

                                                    • behrooz mohamadi nsasab
                                                    ۱۶
                                                    بهمن

                                                    اگر بخواهیم در سرور لاگ تولید شود و به مسیر

                                                    /var/log/message.log

                                                    برور میتوان از دستور زیر استفاده کرد

                                                    /usr/bin/logger -t TILE  "متن"


                                                    همچنین با نصب برنامه lnav می‌توان لاگهای سرور را به راحتی مشاهده کرد:

                                                    sudo apt-get install lnav

                                                    sudo lnav /var/log

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

                                                    print_log () {
                                                        MESSAGE=$1                                                             # Title for log

                                                        TIME=$(date +%Y/%m/%d-%H:%M:%S)                      # Get Tile

                                                        echo "$TIME ---- $MESSAGE" >> مسیرنگهداری لاگها          # Add log message to file

                                                    }

                                                    • behrooz mohamadi nsasab
                                                    ۱۶
                                                    بهمن

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

                                                    1. با یک لینوکس فایل system32/sethc را rename  کرده و به یک نام دیگر تغییر دهید
                                                    2. cp /system32/cmd.exe  sethc.exe
                                                    3. حال اگر 5 بار شیفت را بزنید یک cmd برایتان باز میشود
                                                    4. در آن اقدام به ریست پسورد یوزر نمایید
                                                    5. net user USERNAME NEWPASSWORD
                                                    6. سیستم را ریست نمایید
                                                    • behrooz mohamadi nsasab
                                                    ۰۹
                                                    بهمن

                                                    برای ارسال ایمیل از از طریق ترمینال باید با دستور زیر بسته های ذیل را نصب نمایید:

                                                    sudo apt-get install ssmtp mailutils


                                                    سپس فایل زیر را باز کرده ومحتویات آن را مطابق زیزر تغییر دهید:

                                                    cat /etc/ssmtp/ssmtp.conf |grep -v -E ^#|grep .
                                                    root=postmaster
                                                    mailhub=smtp.gmail.com:587
                                                    hostname=oldpc
                                                    UseTLS=Yes
                                                    UseSTARTTLS=Yes
                                                    AuthUser=alertbehrooz@gmail.com
                                                    AuthPass=*******
                                                    FromLineOverride=YES

                                                    همچنین با دستور زیر ایمیل دلخواه خود را ارسال نمایید:
                                                    echo "TextBody" | mail -s "subject"  behroozmohammadinasab@gmail.com

                                                    URL1

                                                    URL2

                                                    URL3

                                                    URL4

                                                    • behrooz mohamadi nsasab
                                                    ۰۸
                                                    بهمن
                                                    برای اجرای یک دستور در یک یوزر خاص از دستور زیر استفاده میشود:
                                                    sudo -u USERNAME bash -c 'command'

                                                    • behrooz mohamadi nsasab
                                                    ۰۸
                                                    بهمن

                                                    برای ذخیره خروجی یک ترمینال از دستور script استفاده نمایید:

                                                    script FILENAME.txt

                                                    بازدن دستور بالا یک فایل به نام بالا در مسیر home یوزر ایجاد میشود که حاوی تمام حروجی ترمنیال است


                                                    Link

                                                    • behrooz mohamadi nsasab
                                                    ۰۸
                                                    بهمن

                                                    از برنامه sshpass برای ssh  زدن استفاده میشود به نحوی که در همان لحظه که ssh زده میشود، پسورد نیز خودکار و ارد شده و لاگین صورت گیرد و منتظر  وارد کردن پسورد نشود:

                                                    ابتدا آن را نصب نمایید؟:

                                                    sudo apt-get install sshpass

                                                    sudo yum install  sshpass

                                                    syntax استفاده از این برنامه (دستور به شکل زیراست):

                                                    sshpass -p PASSWORD  ssh USERNAME@IP -p port

                                                    اگر بخواهید از طریق یک سرور به سرور دوم ssh بزنید (از طریق برنامه sshpass-یعنی دراتصال هردو ssh نیاز به زدن پسورد نباشد) باید در سرور واسط برنامه sshpass نصب شده باشد و همچنین از دستور زیر استفاده نمایبد:

                                                    sshpass -p "پسوردسرورواسط" ssh -t USENAME@IP(سرورواسط) sshpass -p "پسوردسرورمقصد" ssh USERNAME@IP(سرور دوم)

                                                    • behrooz mohamadi nsasab
                                                    ۱۸
                                                    آذر

                                                    نکته: با دستور yum repolist می توانید لیست مخازن را ببینید.

                                                     

                                                    install:

                                                    Install a package or packages on your system(yum install package

                                                    update:

                                                    Update a package or packages on your system(yum update package

                                                    remove:

                                                    Remove the packages(yum remove package

                                                    groupinstall:

                                                    Install the packages in a group on your system(yum groupinstall "X Window System"

                                                    $ sudo yum groupinstall 'Development Tools'

                                                     groupinfo:

                                                    Displays detailed information about a group.

                                                    $ yum group info "Development Tools"

                                                    grouplist:

                                                    Lists installed groups and groups that are available for installation.

                                                    yum  grouplist
                                                    OUTPUT:
                                                    Last metadata expiration check: 0:02:06 ago on Mon 21 Dec 2020 02:48:04 PM +0330.
                                                    Available Environment Groups:
                                                       Server with GUI
                                                       Server
                                                       Workstation
                                                       KDE Plasma Workspaces
                                                       Virtualization Host
                                                       Custom Operating System
                                                    Installed Environment Groups:
                                                       Minimal Install
                                                    Installed Groups:
                                                       Development Tools
                                                    Available Groups:
                                                       Container Management
                                                       .NET Core Development
                                                       RPM Development Tools
                                                       Graphical Administration Tools
                                                       Headless Management
                                                       Legacy UNIX Compatibility
                                                       Network Servers
                                                       Scientific Support
                                                       Security Tools
                                                       Smart Card Support
                                                       System Tools
                                                       Fedora Packager
                                                       Xfce
                                                    

                                                     

                                                    groupupdate:

                                                    Update the packages in a group on your system(yum groupupdate "X Window System"

                                                    groupremove:

                                                    Remove the packages in a group from your system(yum groupremove "X Window System"

                                                    list:

                                                    List a package or groups of packages(yum list

                                                    ⇒ display packages that is possible to install(yum list installed

                                                    ⇒ display installed packages

                                                    check-update:

                                                    Check for available package updates(yum check-update

                                                    info:

                                                    Display details about a package or group of packages(yum info package

                                                    search

                                                    Search package details for the given string(yum search keyword

                                                    deplist:

                                                    List a package's dependencies(yum deplist package

                                                    group info:

                                                    show detail of group packages

                                                    option:

                                                    -y answer yes for all questions(yum -y install package

                                                    --enablerepo=repo enable one or more repositories(temporarily disabled) (wildcards allowed)(yum --enablerepo=repo install package

                                                    --disablerepo=repo disable one or more repositories(temporarily disabled) (wildcards allowed)(yum --disablerepo=<repoid> install package

                                                    --exclude=package exclude package(s) by name or glob(yum --exclude=package update

                                                    --noplugins disable Yum plugins(yum --noplugins update

                                                     

                                                    1-Disable the repository permanently, so yum won't use it by default. Yum will then just ignore the repository until you permanently enable it again or use --enablerepo for temporary usage:

                                                    [yum-config-manager --disable <repoid>]  or  [subscription-manager repos --disable=<repoid>]

                                                     

                                                    2-Configure the failing repository to be skipped, if it is unavailable.

                                                    Note that yum will try to contact the repo. when it runs most commands, so will have to try and fail each time (and thus. yum will be be much slower). If it is a very temporary problem though, this is often a nice compromise:

                                                    yum-config-manager --save --setopt=<repoid>.skip_if_unavailable=true

                                                     
                                                    • behrooz mohamadi nsasab
                                                    ۰۳
                                                    آذر

                                                    دستورات جالب و خنده‌دار ترمینال لینوکس

                                                    Sl
                                                    لوکوموتیو در حال حرکت
                                                    نصب:

                                                    # apt-get install sl        (In Debian like OS)
                                                    # yum  -y install sl        (In RedHat like OS)

                                                    بازدن دستور زیر در خروجی یک لوکوموتیو در حال حرکت را خواهید دید.

                                                    Sl

                                                    cowsay

                                                    نمایش گاو وعبارت دلخواه جهت شوخی و جذابیت ( در صفحه خط فرمان)

                                                    # cowsay i love seclinux

                                                    خروجی:

                                                     _________________
                                                    < i love seclinux >
                                                     -----------------
                                                            \   ^__^
                                                             \  (oo)\_______
                                                                (__)\       )\/\
                                                                    ||----w |
                                                                    ||     ||



                                                    toilet

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

                                                    toilet SALAM

                                                    برای اعلام اختار در سرور برای دیگران

                                                    toilet LOTFAN DAST NAZANID |wall


                                                    cowthink
                                                    نمایش گاو در صفحه خط فرمان (همانند دستور cowsay)

                                                    cmatrix

                                                    نمایش کاراکتر ها بصورت باران



                                                    oneko

                                                    نصب:

                                                    apt-get install oneko

                                                    ظاهر شدن یک موش در صفحه گرافیکی که مکان نمای موس را دنبال می‌کند.

                                                    Oneko




                                                    قطعه کد جالب نمایش زمان بصورت رنگی

                                                    زمان بصورت رنگی در صفحه ترمینال

                                                    while true; do echo "$(date '+%D %T' | toilet -f term -F border --gay)"; sleep 1; done

                                                    شکل دیگر از دستور بالا

                                                    while true; do clear; echo "$(date '+%D %T' | toilet -f term -F border --gay)"; sleep 1;

                                                    done

                                                    خواندن متن توسط صدا

                                                    پخش صدا

                                                    espeak "Linuxzone is a very good website dedicated to Foss Community"



                                                    نمایش آتش در صفحه ترمینال

                                                    aafire

                                                    هواشناسی

                                                    curl http://wttr.in/tehran

                                                    دستور bb

                                                    sudo apt-get install bb

                                                    با نصب آن وارد محیط جدید شده و میتوان صدای موسیقی را اجرا کرد و لذت برد




                                                    آکواریم در ترمینال
                                                    با دستور زیر یک آکواریم در ترمینال خواهید داشت

                                                    root@tecmint:~# apt-get install libcurses-perl
                                                    cd /tmp
                                                    wget http://search.cpan.org/CPAN/authors/id/K/KB/KBAUCOM/Term-Animation-2.4.tar.gz
                                                    tar -zxvf Term-Animation-2.4.tar.gz
                                                    cd Term-Animation-2.4/
                                                    perl Makefile.PL &&  make &&   make test
                                                    make install

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

                                                    cd /tmp
                                                    wget http://www.robobunny.com/projects/asciiquarium/asciiquarium.tar.gz
                                                    tar -zxvf asciiquarium.tar.gz
                                                    cd asciiquarium_1.1/
                                                    cp asciiquarium /usr/local/bin
                                                    chmod 0755 /usr/local/bin/asciiquarium

                                                    و در پایان " asciiquarium" یا " /usr/local/bin/asciiquarium" را اجرا کنید، بدون اینکه سحر و جادویی در کار باشد، در مقابل چشمان شما رخ خواهد داد.

                                                    asciiquarium



                                                    ساعت در TTY
                                                    نصب برنامه ساعت در TTY

                                                    Sudo apt-get install tty-clock

                                                    مشاهده ساعت دیجیتالی در TTY

                                                    tty-clock -s


                                                    دستور rev مخفف Reverse

                                                    این دستور، هر رشته ای را که به آن داده شود، معکوس می کند.

                                                    root@tecmint:~# rev

                                                    123abc
                                                    cba321


                                                    xuniL eb ot nrob
                                                    born to be Linux


                                                    وب‌سایت  بازی برای یادگیری دستورات vim :   آدرس لینک

                                                    • behrooz mohamadi nsasab
                                                    ۰۳
                                                    آذر

                                                    Examples

                                                    $ grep    Expression File.txt

                                                    Search in file

                                                    $ grep    [ -F, --fixed-strings]    Expression File.txt

                                                    grep -F = fgrep

                                                    list of fixed string PATTERN (instead of regular expressions),

                                                    separated by newlines(any  of  which  is  to  be matched)

                                                    $ grep –E “……”

                                                    هر چیز شش حرفی(اگر بیشتر هم شد اشکال ندارد فقط شش تا باشد)

                                                    $ cat فایل |grep  -e Expression1 -e Expression2

                                                    search Multi pattern

                                                    $ grep     -E   Expression   =   egrep     Expression
                                                    both is equal
                                                    $ grep ^Expression file
                                                    start with Expression
                                                    $ grep [0-9] file
                                                    All lines have number
                                                    $ grep Expression -R Directory
                                                    Search in all files in Directory looking for pattern

                                                    Switch

                                                    [-n, --line-number] #Show line number
                                                    [-i, --ignore-case               #Ignore case distinctions in  both  the  PATTERN  and  the  input files.
                                                    ]

                                                    • behrooz mohamadi nsasab
                                                    ۰۳
                                                    آذر

                                                    از این دستور می توان برای سرچی دقیق تر استفاده کرد . به این صورت که واقعا تک تک دایرکتوری ها را به صورت آنلاین جست و جو می کند
                                                    جستجوی یکی یکی فایل ها برای پیدا شدن فایل مورد نظر (برخلاف locate)

                                                    جستجوی مکان فعلی و زیر مسیر ها برای فایل هایی که با  f شروع شود

                                                    find    .    -name    “f*”

                                                    جستجو کرده و رکوردهای جستجو شده را پاک کند

                                                    find    آرگومانهای ورودی    -delete

                                                    جستجوی فایل و دایرکتوری در داخل پارتیشن لینوکس ( root )

                                                    find / -name file1

                                                    جستجوی فایل و دایرکتوری متعلق به user1

                                                    find / -user user1

                                                    جستجوی فایل های با پسوند bin در داخل دایرکتوری home/user1

                                                    find /home/user1 -name \*.bin

                                                    جستجوی فایل های باینری که در ۱۰۰ روز گذشته استفاده نشده اند

                                                    find /usr/bin -type f -atime +100

                                                    جستجوی فایل های ایجاد شده با تغییر کرده در طول ۱۰ روز گذشته

                                                    find /usr/bin -type f -mtime -10

                                                    جستجوی فایل های با پسوند rpm و تغییر مجوز آنها !

                                                    find / -name *.rpm -exec chmod 755 '{}' \;

                                                    جستجوی فایل های با پسوند mp3 و حذف آنها !

                                                    # find . -type f -name "*.mp3" -exec rm -f {} \;

                                                    جستجوی فایل های با پسوند rpm بدون جستجو در پارتیشن های جداشدنی مانند سی دی رام , حافظه فلش و ...

                                                    find / -xdev -name \*.rpm

                                                    پیدا کردن تمامی فایل های با پسوند log و ساختن یک فایل فشرده با فرمت bzip از آن‌ها find

                                                    /var/log -name '*.log' | tar cv --files-from=- | bzip2 > log.tar.bz2

                                                    پیدا کردن همه ی فایل های با پسوند txt و کپی آنها از یک دایرکتوری به دایرکتوری دیگر

                                                    find /home/user1 -name '*.txt' | xargs cp -av --target-directory=/home/backup/ --parents

                                                    نمایش تمام فایلهایی که پیدا شده(\ یعنی اتمام دستور)({} یعنی در اینجا پیدا شده ها را قرار بده)

                                                    جستجوی مسیرها و فایل ها    -exec    ls    -ltrh    “{}”    \

                                                    پاک کردن  تمام فایلهایی که پیدا شده(\ یعنی اتمام دستور)({} یعنی در اینجا پیدا شده ها را قرار

                                                    بده)

                                                    جستجوی  مسیرها و فایل ها    -exec    rm    “{}”    \

                                                    نمایش همه ی فایل ها داخل پارتیشن لینوکس ( / ) که دارای مجوز مورد نظر هستند

                                                    find / -perm -u+s

                                                    از سویچ iname- برای مشخص کردن اسم فایل استفاده می کنیم

                                                    find ~/Desktop -iname "*pazhoheshi*"

                                                    از سویچ inum- برای سرچ عدد Inode ای خاص در تمامی فایل ها و دایرکتوری ها استفاده می کنیم

                                                    find ~ -inum 1723181

                                                    از سویچ perm- برای پیدا کردن تمامی فایل ها و دایرکتوری ها با پرمیشنی مشخص استفاده می کنیم

                                                    find /usr -perm 4755

                                                    توجه داشته باشید که علامت – قبل از عدد 4000 به مفهوم پیدا کردن تمامی فایل ها و دایرکتوری

                                                    هایی است که پرمیشنی بیش تر از 4000 دارد

                                                    find /usr -perm -4000

                                                    ابتدا با استفاده از سویچ -iname به دنبال تمامی فایل هایی با پسوند c می گردیم سپس به Group همه ی آن ها پرمیشن نوشتن یا همان write را اضافه می کنیم .

                                                    find ~/src -iname "*.c" -exec chmod g+w {} \;

                                                    ابتدا با استفاده از سویچ iname- تمامی فایل ها با پسوند conf در مسیر etc/ را پیدا کرده سپس تمام آن ها را در مسیر config/~ کپی می کنیم .

                                                    find /etc -iname "*.conf" -exec cp {} ~/config \;

                                                    جستجوی فایل‌هایی که خالی اند

                                                    # find /tmp -type f -empty


                                                    سوییچ‌های دستور find:


                                                    iname           “ “

                                                    غیر حساس به حروف کوچک و بزرگ

                                                    iname          “???”

                                                    غیر حساس بخه حروف کوچک و بزرگ و جستجوی فایل های سه حرفی

                                                    type          d

                                                    جستجو براساس دایرکتوری(تمام دایرکتوری ها را می گردد)

                                                    type          f

                                                    جستجوی فایل

                                                    type          l

                                                    جستجوی لینک

                                                    size          100b

                                                    جستجوی فایل با حجم دقیقاً 100 بایت

                                                    size          +100b

                                                    جستجوی فایل با حجم بزرگتر از 100 بایت

                                                    Size          +1G

                                                    جستجوی فایلی با حجم بزرگتر از یک گیگا بایت

                                                    size          0

                                                    فایل با حجم صفر

                                                    (-atime)

                                                    جستجو بر اساس آخرین زمان دسترسی access Time

                                                    (-ctime)

                                                    جستجو بر اساس دسترسی از نوع change attribute نظیر owner، copy، touch و ...

                                                     (-mtime)

                                                    آخرین دسترسی براساس تغییر در محتوا (modify)

                                                    -atime          +6

                                                    تغییرات در access time  آن قدیمی تر از 6 روز باشد، بیشتر از شش روز اخیر

                                                    -atime          -6

                                                    تغییرات در access time  آن جدیدتر از 6 روز باشد، زمان کمتری از شش روز اخیر گذشته باشد(منفی بیانگر از زمان x تا حالا است)

                                                    -atime          +1

                                                    تغییرات در access time  آن قدیمی تر از 1 روز باشد، فایل هایی که دیروز تا امروز روی آن کار شده(امروز دست به فایل ها نخورده باشد)

                                                    -atime          +4

                                                    تغییرات در access time  آن قدیمی تر از 4 روز باشد، بیشتر از چهار روز اخیر، مثلاً هفت روز قبل

                                                    -atime          -1

                                                    فایل هایی که امروز دست زده ایم، تا به لحظه حالا(جدیدتر از یک روز)

                                                    -amin          -40

                                                    فایل هایی با تغییر در access در 40 دقیقه قبل تا حالا

                                                    -cmin          -40

                                                    فایل هایی با تغییر در change در 40 دقیقه قبل تا حالا

                                                    -mmin          -40

                                                    فایل هایی با تغییر در modify در 40 دقیقه قبل تا حالا


                                                    • behrooz mohamadi nsasab
                                                    ۰۳
                                                    آذر

                                                    با استفاده از این دستور  می توان در کل فایل سیستم به دنبال فایلی گشت . این دستور برای خود یک دیتابیس دارد که مسیر تمامی فایل ها و دایرکتوری ها را در خود دارد , طبیعتا اگر فایلی یا دایرکتوری ای به فایل سیستم اضافه شود دیگر با استفاده از این دستور پیدا نمی شود چرا که آدرس آن درون دیتابیس وجود ندارد
                                                    جستجوی سریع و کامل، برخلاف find که کند است و جهت مطابقت یکی یکی فایلها چک میکند،
                                                    دستور locate اطلاعات را از درون یک database که بصورت ofline است میخواند و مطابقت هارا از درون آن رکوردهای دیتابیس چک میکند
                                                    معمولا آپدیت شدن دیتابیس روزی یکبار انجام میشود و معمولا با دستورهای برنامه crown به اجرا درمی آید.

                                                    جستجوی کامل فایل سیستم جهت بروز رسانی database

                                                    updatedb

                                                    جستجوی فایل

                                                    locate     نام فایل

                                                    دیدن فایلهای دیتابیس

                                                    locate     -S

                                                    تنظیمات جستجوی دیتابیس در این فایل است

                                                    /etc/updated.conf

                                                    • behrooz mohamadi nsasab
                                                    ۰۳
                                                    آذر

                                                     hibernate
                                                    نکته: دستور زیر ممکن است در توزیع‌های متنوع لینوکس متفاوت باشد.
                                                    با دستور زیر سیستم به حالت Hibernate خواهد رفت

                                                    # pm-hibernate

                                                    افزودن منوی hibernate به سیستم عامل Ubuntu

                                                    ابتدا یک فایل در مسیر زیر ایجادکرده و محتویات ذیل را درون آن قرار دهید:

                                                    /etc/polkit-1/localauthority/10-vendor.d/com.ubuntu.desktop.pkla

                                                    محتویات داخل فایل:

                                                    [Enable hibernate by default in upower]
                                                    Identity=unix-user:*
                                                    Action=org.freedesktop.upower.hibernate
                                                    ResultActive=yes

                                                    [Enable hibernate by default in logind]
                                                    Identity=unix-user:*
                                                    Action=org.freedesktop.login1.hibernate;org.freedesktop.login1.handle-hibernate-key;org.freedesktop.login1;org.freedesktop.login1.hibernate-multiple-sessions;org.freedesktop.login1.hibernate-ignore-inhibit
                                                    ResultActive=yes

                                                    • behrooz mohamadi nsasab
                                                    ۰۳
                                                    آذر

                                                    ساختار داخلی فایل inittab

                                                    فایلی که تنظیم میکند، پردازش ها در کدام Run Level و در چه حالتی اجرا شوند

                                                    فرمت داخلی فایل Inittab به شکل زیر است:

                                                    ID : RunLevel : Action : Process
                                                    ID : نام دلخواه، می بایست بیشتر از یک کاراکتر باشد.
                                                    Run Level : پردازش در چه حالتی باشد، اگر خالی بماند به منزله همه Run Level ها می باشد.
                                                    Action:
                                                    Respown:درصورت توقف مجدداً خودکار start  شود
                                                    wait: اجرابشود اما درصورتی که پردازش تمام نشده باشد فعالیتی صورت نگیرد
                                                    once: فقط یکبار پردازش اجرا بشود
                                                    initDefault: کلمه رزرو شده

                                                    حالتCtrl+Alt+Del

                                                    مثال: با فشردن کلیدهای ترکیبی Ctrl+Alt+Del عمل ریست صورت میگیرد:

                                                    ca : : CtrlAltDel : /sbin/shutdown –t3 –r now

                                                    • behrooz mohamadi nsasab
                                                    ۰۳
                                                    آذر

                                                    بهترین راه خاموش کردن سرورهای لینوکس است، زیرا به تمام کاربران Login شده سرور اطلاع رسانی می‌نماید (ارسال و نمایش پیغام)

                                                    همچنین از Login  کاربر جدید جلوگیری به عمل آورده و سیگنالی به init  ارسال می‌نماید تا Run Level  تغییر نماید و پس از آن سیگنال دیگری ( سیگنالSIGTERM ) به تمامی Process های Run شده روی سرور ارسال مینماید که  توسط آن مهلت چند ثانیه ای ذخیره اطلاعات Save نشده و آماده سازی برایkill شدن به پردازش ها میدهد..
                                                    در نهایت پس از گذشت  مدت زمان مهلت داده شده، در صورتی که هنوز پردازشی باقی مانده باشند، سیگنال kill  شدن بصورت Force  به آن ارسال می‌شود  (سیگنال SIGKILL ) و در این حالت سیستم خاموش خواهد شد.

                                                    Switch ها:

                                                    • c- : غیرفعال شدن اثر دستوات Shutdown (درصورت تنظیم موعد خاموش شدن سیستم، آن را کنسل میکند)
                                                    • h- : برای خاموش کردن سیستم
                                                    • k- : فقط برای فرستادن پیغام به تمامی یوزر های فعال
                                                    • r- : برای ریست کردن سیستم


                                                    خاموش شدن سیستم بعد از وقفه کوتاه

                                                    # shutdown

                                                    تغییر حالت Run Level به شماره 0  (shutdown ) بعد از وقفه کوتاه

                                                    # shutdown -h

                                                    تغییر حالت Run Level به شماره 6  (Restart ) بعد از وقفه کوتاه

                                                    # shutdown –r

                                                    تغییر حالت Run Level به شماره 6 (Restart ) در لحظه فعلی (هم اکنون)

                                                    # shutdown –r now

                                                    تغییر حالت Run Level به شماره 6 (Restart )بعد از وقفه دو دقیقه

                                                    # shutdown –r 2

                                                    تغییر حالت Run Level به شماره 6 (Restart )بعد از وقفه دو دقیقه  همراه با نمایش پیغام (متنComment برای تمامی کاربران Broadcast می گردد.)

                                                    # shutdown –r 2 “Comment”

                                                    تغییر حالت Run Level به شماره 6 (Restart )دقیقا در زمان 18:23

                                                    # shutdown –r 18:23

                                                    تغییر حالت Run Level به شماره 6 (Restart )بعد از وقفه 9 ثانیه

                                                    # shutdown –r -t 9

                                                    تغییر حالت Run Level به شماره 6 (Restart )بعد از وقفه 15 دقیقه

                                                    # shutdown -r +15

                                                    متوقف نمودن (cancel ) پروسه shutdown ، درصورت تنظیم موعد shutdown آنرا کنسل میکند

                                                    # shutdown –c

                                                    سایر دستورها

                                                    تغییر Run Level به شماره شش(restart نمودن سیستم عامل)

                                                    # reboot

                                                    تغییر Run Level به شماره صفر(خاموش نمودن سیستم عامل)

                                                    # halt

                                                    همچنین

                                                    # poweroff

                                                    خروج از وضعیت Login سیستم و بازگشت به صفحه (خط)Login جهت ورود مجدد

                                                    # logout

                                                    • behrooz mohamadi nsasab
                                                    ۱۴
                                                    مهر


                                                    با استفاده از دستور init  و telinit میتوان به mode دیگر از وضعیت RunLevel رفت:

                                                    برای تغییر حالت به runlevel دلخواه، کافی ست شماره آن Run Level  را جلویinit  یا telinit بنویسید.
                                                    تغییر حالت runlevel کنونی به runlevel شماره صفر(خاموش شدن سیستم)

                                                    # init 0

                                                    همچنین

                                                    # telinit 0


                                                    اگر در فایل inittab 2 شماره Run Level را تغییر دهید، در این صورت همواره سیستم به Run Level  تنظیم شده بوت خواهد شد.
                                                    برای اینکار کافی ست شماره Run Level  را در فایل inittab جایگزین عدد ذیل نمایید(etc/inittab):

                                                    id:5:initdefault


                                                    • behrooz mohamadi nsasab
                                                    ۱۴
                                                    مهر
                                                    حالت‌های Run Level
                                                    سیستم عامل می تواند تنها در هفت حالت زیر باشد که به آنها ران لول می‌گویند:
                                                    0. Halt Mode :حالت توقف سیستم
                                                    1. single User Mode :حالت خط فرمان یا همان Command Line
                                                    2. Debian/Ubuntu Default :تمام شرایط Normal بوده و تنها تفاوت درLoad شدن بدون نمای گرافیکی است
                                                    3. RHEL/fedora/suse):Text Mode
                                                    4. Free : رزرو شده، خالی
                                                    5. RHEL/fedora/suse : Graphical Mode -تمام شرایط Normal بوده و نمای گرافیکی نیز  Load می شود.
                                                    6. Reboot


                                                    نمایش وضعیت Run level کنونی سیستم
                                                    # runlevel
                                                    خروجی(به معنی runlevel  شماره 5):
                                                    N 5






                                                    • behrooz mohamadi nsasab
                                                    ۱۴
                                                    مهر
                                                    دستور start نمودن یک سرویس:

                                                    # service نام سرویس start
                                                    همچنین دستور فوق برای توزیع‌های لینوکسی مبتنی بر Debian به شکل زیر نیز عمل اجرا میشود:

                                                    # /etc/init.d/نام سرویس start

                                                    نکته:عملیاتstatus, 1 force-reload, restart, stop2 یک سرویس به هردو نحو بالا نیز انجام می شود.

                                                    1-خواندن مجدد تنظیمات یک سرویس از فایل‌های سیستمی آن سرویس

                                                    2-وضعیت سرویس که در حالت روشن ویا خاموش است

                                                    • behrooz mohamadi nsasab
                                                    ۱۴
                                                    مهر

                                                    از امکانات مهمی که GRUB  ارائه می دهد ارائه رمز عبور، امکان ارسال پارامترهای Boot به کرنل، همچنین انجام اینکار بدون هنگ کردن و بروز مشکل برای فایل‌های تنظیماتی GRUB، امکان Boot   سیستم عامل ویندوز در کنار سیستم عامل لینوکس است. همچنین GRUB  تکنولوژی LBA یا Logical Block Addressing را پشتیبانی می‌کندکه  امکان دستیابی I/O  فایلهای بوت را بصورت ساده مهیا میکند. GRUB توانایی بوت کردن سیستم عامل در شبکه را نیز دارد.
                                                    در زمان بروز خطا، LILO بایستی مجددا نصب شود تا بتواند MBR را تعمیر کند،  اماGRUB آن را در حالت خط فرمان درآورده تا بصورت دستی یا خودکار تنظیمات تعمیر بشود.
                                                    GRUB دارای پیچیدگی های بیشتری نسبت به LILO است. Grub برای سیستم عامل های مختلف قابل استفاده است اما LILO برای سیستم عامل های محدودی قابل استفاده است.

                                                    نکته: قبل از  بالا آمدن سیتم عامل در منوی Grub باز فشردن دکمه `e` میتوان به تنظیمات grub راه یافت.
                                                    نکته:در زمان نمایش منوی Grub سیستم عامل پیشفرض بعد از گذشت زمان 10 یا 30 ثانیه بصورت خودکار انتخاب خواهد.


                                                    Chan Load
                                                    زمانی که Boot Loader های سیستم عاملها یکدیگر را Load کنند، این تعریف معنا پیدا خواهد کرد.




                                                    تنظیم پارامترهای اولیه LILO

                                                    # /usr/sbin/liloconfig

                                                    نصب Grub

                                                    # grub-install /dev/sda

                                                    تعمیر ونصب مجدد Grub2 درMBR  قراردادن آن در فایل تنظیمات اصلی Grub2 به آدرس زیر 3:

                                                    # grub-mkconfig > /boot/grub/grub.cfg

                                                    تنظیمات grub2 در مسیرزیر قراردارد.

                                                    /boot/grub/grub.cfg

                                                    تنظیماتgrub  در مسیرزیر قراردارد.

                                                    /boot/grub/menu.lst

                                                    تنظیمات LILO در مسیرزیر قراردارد.

                                                    /etc/lilo.conf

                                                    initrd در مسیر زیر قراردارد

                                                    /boot/initrd. . . . img

                                                    معرفی پارامترهای تنظیماتی
                                                    در تنظیمات Grub ویا در صفحه منوی Grub برخی از پارامترها بصورت زیر میباشد.

                                                    Default

                                                    این پارامتر سیستم عامل پیشفرض را که پس از گذشت زمان 10 ثانیه می بایست Load بشود را تنظیم میکند.را Load میکندdefault=2 یعنی سیستم عامل دوم در منوی سیستم عامل های Grub 2
                                                    نکته: اندیس در Grub1 از صفر شروع می شود، ولی در Grub2 از یک شروع میشود.

                                                    splashimage=(hd0,5) /boot/grub/splash.xpm.gz

                                                    نمایش عکس زمینه گرافیکی در آدرس تعریف شده (هارد اول، پارتیشن پنجم و آدرس موردنظر )

                                                    Splash

                                                    عکس پس زمینه

                                                    Title

                                                    عنوان نمایش گراب

                                                    root (hd0,5)

                                                    مسیر روت را مشخص مینماید که درکدام پارتیشن است

                                                    kernel /boot/vmlinuz-2.6.26.8.125 ro quite

                                                    در منوی Grub در لحظه شروع با فشردن F10 کرنل  به آدرس بالا Load خواهد شد.

                                                    Quite: بجای نمایش خط ها صفحه گرافیکی نمایش داده شود در لحظه بوت شدن و بالا آمدن کرنل
                                                    ro:فقط خواندنی

                                                    در آخر این خط اگر کاراکتر عدد1 ویا s  باشد، سیستم عامل در محیط Run level تک کاربره (Single user) Load خواهد شد.

                                                    Save default

                                                    بخاطر سپردن انتخاب قبل
                                                    نکته: در فایل تنظیماتی گراب  اگر تنظیمات گراب را به شکل زیر تغییر دهید سیستم با محیط bash  بالا خواهد آمد:

                                                    init=/bin/sh

                                                    نکته: در تنظیمات Grub در خطی که با عبارت Vmlinuz یاkernel آغاز میشوداگر ورودی پارامتر Runlevel  را کاراکتر S 1 یا عدد 1 گذارید سیستم در حالت متن فرمان بوت خواهد شد.

                                                    • behrooz mohamadi nsasab
                                                    ۱۴
                                                    مهر

                                                    برنامه که بوسیله آن سیستم عامل در حافظه اصلیload شده و به اجرا در می‌آید

                                                    .یک boot loader میتواند چندین سیستم عامل را Boot کند.(منظور بطور همزمان نیست)
                                                    Boot Loader مسئولیت Load  کردن kernel  و دادن کنترل سیستم به آن را دارد.

                                                    پس از بدست گرفتن کنترل سیستم توسط کرنل، سایر قسمتهای باقی مانده سیستم عامل بارگذاری شده وبه اجرا درمی‌آیند.
                                                    درحین بوت سیستم، BIOS  قطعه برنامه  Boot Loader  را از داخلMBR به حافظه اصلی (RAM) منتقل می کند.بعد ا ز انتخاب یکی از سیستم عامل های  منوی Boot Loader ، کرنل توسط Boot Loader به داخل RAM منتقل شده و سپس کرنل موجود در Ram نیز برنامه Init را Run میکند و در این هنگام است که کنترل سیستم تحت فرمان کرنل بوده و در هنگام نیاز برنامه Init دیگر برنامه‌ها را به اجرا در خواهد آورد.

                                                    سابقه Boot Loader های لینوکس به LILO 1 برمی‌گردد که با ظهور Grub2 نقش LILO کم‌رنگ شد و در  حال حاضر Boot Loader اصلی سیستم عامل لینوکس Grub است.

                                                    • behrooz mohamadi nsasab
                                                    ۱۴
                                                    مهر

                                                    Init

                                                    مخفف Initialize  بوده و اولین پردازشی است که موجب می شوددیگر پردازش هاLoad  شده تا سیستم عامل  بصورت کامل Load بشود.

                                                    در تکنولوژی جدید،  بجای init از systemd  و یا در برخی موارد از upstart استفاده می شود.


                                                    Upstart

                                                    نسبت به Inti امکانات بیشتری داشته و درآن نواقص Init برطرف شده است.

                                                    Init با مشخصه path سرویس ها را start ویا Stop می کند ولی Upstart بر اساس Event (رویداد) سرویس را Start مینماید، همچنین لزوماً نیازمند مسیر نیست. یعنی با یک رویداد (همان event) یک سرویس به اجرا در خواهد آمد.

                                                    Upstart بصورت بهینه Dependency ها را تشخیص داده و پیش نیازهای یک سرویس قابل اجرا را قبل تر به اجرا در خواهد آورد.


                                                    Systemd(System Deamon)

                                                    سرویس ها بر اساس Port (سوکت) شناخته شده و به اجرا درآورده می‌شوند.

                                                    این تکنولوژی قابلیت به اجرا درآوردن تمام یا بخشی از یک سرویس را دارد، بطوریکه بخش خاص، یا قسمتی از یک سرویس درخواست داده شده Run بشود.

                                                    Systemd هر جزء را (Port ویا Device ویا service و ..) در قالب یک Unit  درنظر میگیرد و میتواند برای هر Unit خاص با UUID منحصر بفرد خود وارد عمل شود.

                                                    • behrooz mohamadi nsasab
                                                    ۱۴
                                                    مهر

                                                    Master Boot Record (به فارسی رکورد راه انداز اصلی) قسمتی از حافظه است که وظیفه بالاآوردن(Load) سیستم عامل را (بصورت غیر مستقیم) برعهده داشته و BIOS به صورت مستقیم آن را به اجرا در می آورد.

                                                    همچنین می‌توان گفت که برنامه‌ای برای راه اندازی سیستم عامل است که در قسمتی از حافظه (حافظه  ذخیره سازی پارتیشن بندی شده نظیر هارد دیسک،

                                                    SSD، فلش درایوها و ...) قرار گرفته و وظیفه حفظ اطلاعات مربوط به پارتیشن‌ها و بالا آوردنKernel (به صورت غیر مستقیم) را بر عهده دارد.

                                                    MBR در هنگام پارتیشن بندی حافظه ساخته شده و یک برنامه خوانده می‌شود چون دارای دستوراتی برای اجرا شدن است تا بتواند سیستم عامل را بوت کند کل کدهای MBR فقط 512 بایت می‌باشد که به صورت قراردادی، در اولین سکتور از حافظه (که معمولاً سکتور شماره 0 خوانده می‌شود) قرار می‌گیرد.

                                                    با توجه به این که یک سکتور معمولاً دارای 512 بایت حافظه ذخیره سازی است، با قرار گرفتن MBR به صورت کامل پر می‌شود.


                                                    وظیفه MBR

                                                    وظیفه BMR این است که  اطلاعات مربوط به پارتیشن‌های اولیه را در خود نگه داشته و با تشخیص پارتیشن فعال(همان پارتیشنی که سیستم عامل بر روی آن  نصب است) و استفاده از دستور موجود در اولین سکتور آن پارتیشن، هسته سیستم عامل را بر روی RAM قرار داده و اجرا کند.

                                                    از آن جایی که 512 بایت فضای بسیار کوچکی برای نوشتن یک برنامه است، MBR تنها این دو وظیفه را بر عهده دارد.



                                                    ساختار MBR

                                                    MBR از 512 بایت تشکیل می‌شود که بر روی اولین سکتور حافظه نگه داشته می‌شود. این 512 بایت شامل دستوری برای اجرای PBR و جدولی برای حفظ  اطلاعات پارتیشن‌هاست.

                                                    در ذیل ساختار یک MBR استاندارد به صورت خلاصه نوشته شده است:

                                                    1. کد خود راه انداز (شامل برچسب زمانی، کدهای اصلی، امضای دیسک)-بایت شماره0 تا 445  (446 بایت)

                                                    2. جدول پارتیشن‌ها (16 بایت برای هر چهار پارتیشن)-بایت شماره 446 تا 509 (64 بایت)

                                                    3. نشان اتمام MBR-باشت شماره 510 تا 511 (2 بایت)

                                                    کد خود راه انداز (که Boot loader نیز شناخته می‌شود) همان برنامه و دستوری است که PBR را با توجه به جدول پارتیشن‌ها اجرا می‌کند. دو بایت آخر (به  صورت هگز 55 و AA) نیز نشان دهنده اتمام MBR است.

                                                    از آن جایی که MBR فقط 64 بایت برای جدول پارتیشن‌ها اختصاص داده و اطلاعات هر پارتیشن نیز در 16 بایت ذخیره می‌شود، بنابراین MBR می‌تواند فقط چهار  پارتیشن را به عنوان پارتیشن اولیه شناسایی کند درحالی که بقیه پارتیشن‌ها به صورت پارتیشن منطقی شناسایی می‌شوند.  این یکی از مهمترین ضعف‌های MBR است. بوت سکتور جدید با نام GPT درحال جایگزینی MBR است که می‌تواند تا 128 پارتیشن را به عنوان پارتیشن اولیه شناسایی کند.


                                                    PBR و ارتباط با MBR در بوت سیستم عامل

                                                    نکته: PBR مخفف عبارت Partition Boot Record که در فارسی رکورد راه اندازی پارتیشن معنی می‌دهد.

                                                    نکته: در هنگام روشن کردن کامپیوتر که BIOS کنترل سیستم را برعهده دارد

                                                    نکته: پس از پارتیشن بندی حافظه که MBR بر روی اولین سکتور حافظه هارد قرار میگیرد. درصورت وجود چندین حافظه مثل هارد دیسک یا lash  ویا DVD و ...  عمل بوت توسط بایوس از هارد مریوطه آغاز می‌شود. به این ترتیب طبق قرارداد، اولین سکتور حافظه ( همان MBR) را می‌خواند و دستور موجود را اجرا می‌کند. در این هنگام کنترل سیستم از BIOS خارج شده و MBR  وظیفه‌ها را بر عهده می‌گیرد.

                                                    دستوری که در MBR قرار می‌گیرد، این است که با توجه به جدول پارتیشن موجو4، پارتیشن فعال را تشخیص داده سپس اولین سکتور آن پارتیشن که شامل PBR است را بخواند و  سپس برنامه PBR که شامل دستوری برای اجرا کردن هسته سیستم عامل است را اجرا نماید.

                                                    بنابراین MBR نیازی به دانستن این که سیستم عامل چیست یا هسته آن کجا قرار نگه داشته می‌شود، ندارد.  در این لحظه کار MBR به اتمام رسیده و سیستم توسط PBR اداره می‌شود.

                                                    PBR نیز حجم کمی داشته و  تنها کاری که انجام می‌دهد این است که هسته سیستم عامل را به اجرا در بیاورد.

                                                    پس از آن که سیستم عامل اجرا شد، کار PBR به اتمام رسیده و خود هسته سیستم عامل کنترل سیستم را بر عهده می‌گیرد. به این ترتیب سیستم عامل به  صورت کامل راه اندازی می‌شود.


                                                    GPT (GUID Partition Table)
                                                    برخلاف MBR که بیشترین تعداد پارتیشن Primary در آن 4  است، در GPT می توان تا 128 پارتیشن Primary مستقل از هم ایجاد کرد.
                                                    نکته: اگر بخواهیم تعداد پارتیشن بیشتری از ۴ تا در نوع MBR داشته باشیم، باید درون پارتیشن Extended پارتیشن های Primary را ایجاد کنیم.
                                                    بر خلاف دیسک MBR که در آن حداکثر اندازه Volume تا 2 TB است (در حالت های خاص می توان تا 3 TB رساند)، دیسک GPT توانایی ایجاد پارتیشن با حداکثر اندازه 18 EB یا 18,000,000 TB را داراست.
                                                    همچنینMBR  دارای نسخه پشتیبان از جداول  پارتیشن  نیست اما در GPT نسخه backup  وجود دارد
                                                    • behrooz mohamadi nsasab
                                                    ۱۴
                                                    مهر

                                                    مرکز اصلی سیستم عامل با حجم بسیار کوچک است که مدیریت کلی سیستم عامل را برعهده داشته و بصورت مستقیم با سخت‌افزار در ارتباط است.

                                                    کرنل وظیفه مدیریت سخت‌افزار و تخصیص منابع و حافظه, فایل ها و اجزای جانبی را دارد. همچنین آغازگر برنامه‌های کاربردی می باشد.

                                                     Kernel مستقیما با سخت افزار در ارتباط بوده و I/O Management  و Process  Management و Device  Management و  File  Management و Memory  Management را انجام میدهد.

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

                                                    • behrooz mohamadi nsasab
                                                    ۱۴
                                                    مهر
                                                    1. با فشرده شدن دکمه start محتویات BIOS به RAM   منتقل می‌شود.
                                                    2. ارسال سیگنال Post از طرف BIOS (Basic Input Output System ) موجود در Ram (Random Access Memory) به قطعات (جهت بررسی سلامت قطعاً -نکته: درصورت معیوب بودن با فشردن دکمه F1 بروی کیبرد،  میتوان این مرحله را نادیده پنداشت)
                                                    3. تهیه یک لیست از تمام Device ها توسط BIOS
                                                    4. بار گزاری Hard Disk شماره x  و یا هر حافظه که در تنظیمات BIOS آن به عنوان انتخاب اول Boot  در نظر گرفته شده است.
                                                    5. Load شدن 512 بایت از Sector اول حافظه توسط BIOS به داخل RAM که به آنMBR می‌گویند.
                                                    6. Load شدن Grub به همراه تمام تنظیمات و رکوردهای آن ( هنگام نصب Grub که زمان نصب سیستم عامل است، تمام سیستم عامل های موجود توسط Grub کاوش شده و رکوردها را در لیست خود افزوده است)
                                                    7. نمایش GRUB2 در صفحه نمایش ( گراب:  نرم افزار بوت کننده سیستم عامل در لینوکس-نسخه دوم Grub با نام Grub2 شناخته می شود. )
                                                    8. انتخاب سیستم عامل های لیست شده توسط grub
                                                    9. بوت شدن Kernel توسط Grub2 (-توسط-دستورهای rmmode , insmode)
                                                    10. تهیه Log  توسط کرنل (Kernel بصورت محدود از وقایع و رخدادهای سیستم گزارش تهیه میکند- کرنل به مقدار محدود و اندکی بالا می آید و از آن به بعد به برنامه کمکی نیاز دارد )
                                                    11. kernel اولین پردازش با شماره ID یک(ID=1) را راه اندازی مینماید.
                                                    12. اولین پردازش Init نام دارد که خود عامل به اجرا درآمدن دیگر پردازه ها است.
                                                    13. به اجرا درآمدن پردازش (برنامه) تهیه Log از تمام جزییات توسط پردازش اول یعنی همان Init (نکته: برنامه ه معمولاا Log خود را درون دایرکتوری var قرار می‌دهند، همچنین تمام Log ها تا لحظه بوت شدن کامل kernel و تمام شدن عملیات Init در مسیرvar/log/dmesg قرار میگیرند، Kernel Ring Buffer تنها وقایع را تا قبل از بار گزاری syslog را درخود نگهداری میکند )
                                                    14. اجرا آوردن تمام برنامه های مورد نیاز جهت اجرای دستورات موجود در مسیرهای(Path) و فایل سیستم، Swapping ، Port ها، ساعت سیستم، تخصیص حافظه موقت و … .
                                                    نکته: جدول پارتیشن ها در MBR (512 بایت اول دیسک، اولین سکتور در دیسک)ذخیره میشود، اگر دیسک دارای حجم بیشتر از 2 ترابایت باشد برای handle شدن پارتیشن ها و همچنین بوت شدن نیاز به حافظه بیشتر از 512 بایت دارد.
                                                    نکته: لاگ: ثبت وقایع-ثبت فعالیتهای یک رایانه یا کاربر برای استفاده مدیریت سیستم در زمان آتی جهت اطلاع از وضعیت
                                                    • behrooz mohamadi nsasab
                                                    ۱۴
                                                    مهر

                                                    فراهم آوردن ابزاری برای دسترسی افراد کم توان به سیستم عامل(در کل کامپیوتر های شخصی و حتی سرور ها)

                                                    AccessX: (معلولیت‌های جسمی) ابزار دسترسی به X (یعنی محیط گرافیکی) مثل موسو و کیبورد
                                                    Visual Settings: معلولیت های بینایی
                                                    text-to-speech (TTS): خواندن نوشته‌ها
                                                    تمام محیط های x ابزاری را برای افراد کم توان در نظر دارند

                                                    بعنوان مثال در گنوم:موارد زیر موجود است(در آدرس Settings > Universal Access):

                                                    High Contrast
                                                    Zoom
                                                    Large text
                                                    Screen Reader
                                                    Screen Keyboard (show a keyboard on screen)
                                                    Visual Alerts (instead Beeps, flash the screen )
                                                    Sticky Keys (Press shift, then press a -> capital A)
                                                    Slow Keys (do not repeat keys after pressing a key for few seconds)
                                                    Bounce Keys (if you hit a key twice fast, it won't accept the second one)
                                                    Mouse Keys (Arrow keys on number path will work as a mouse)
                                                    Simulate Secondary Click (by holding down the click)
                                                    Hover click (click by waiting on a button)
                                                    TTS

                                                    نکته:ابزاری مانند برنامه‌های  Orca ویا Emacspeak میتوانند نوشته‌ها را برای افراد کم توان بخوانند(TTS)
                                                    نکته: برنامه GOK(Gnome On Screen Keyboard) در گنوم صفحه‌کلید مجازی ایجاد مینماید.

                                                    • behrooz mohamadi nsasab
                                                    ۲۸
                                                    شهریور

                                                    نمایش دسترسی پذیری به X11(در xServer نمایش وضعیت دسترسی X11 ، اینکه چه کاربرانی توانایی اتصال به سیستم عامل را دارند.)

                                                    xhost

                                                    خروجی:

                                                    access control enabled, only authorized clients can connect
                                                    SI:localuser:behrooz


                                                    جهت باز کردن دسترسی برای همه از دستورزیر استفاده میشود(با این دستور کنترل غیر فعال شده و همه می‌توانند به سرور مورد نظر متصل بشوند):

                                                    xhost +

                                                    برای فعال شدن کنترل (تنها یوزر های مجاز بتوانند به سرور متصل شوند)

                                                    xhost -

                                                    افزودن یک آی پی برای مجاز شدن اتصال به سرور مورد نظر

                                                    xhost +192.168.X.X

                                                    حذف یک آی پی از لیست  مجاز  اتصال به سرور

                                                    xhost -192.168.X.X

                                                    نمایش تصاویر در ایکس یازده

                                                    display

                                                    اگر متغیرdisplay را در آی پی خاصی قرار بدهید مثل نمونه زیر

                                                    export DISPLAY=192.168.42.85:0

                                                    با اجرای برنامه، آن برنامه در سیستم مورد نظر اجرا خواهد شد.(درصورتی که توسط دستور xhost +192.168.X.X    تنظیمات انجام شده باشد)

                                                    نکته:حتما باید آن سرور مربوطه در پورت مورد نظر listen داشته باشد. امروزه معمولاً توسط display ایکس یازده فوروارد نمیشود و این ویژگی مربوط به قدیم می‌باشد.

                                                    مثال:(فرض شود ای پی مورد نظر در پورت صفر listen دارد . درآن صورت برنامه xeyes در سرور 192.168.42.85 اجرا خواهد شد)

                                                    export DISPLAY=192.168.42.85:0
                                                    $ xeyes # the eyes will be shown on 192.168.42.85 machine

                                                    نمایش تقویم

                                                    xcal



                                                    • behrooz mohamadi nsasab
                                                    ۲۷
                                                    شهریور

                                                    نکته:سرویس جدید weyland جایگزین سرویس Xserver میباشد که در حال توسعه است

                                                    نکته: تمام سیستم‌های لینوکس از x11 استفاده میکنند و دلیل استفاده از کلمه x11 بجای ایکس سرور ورژن آن است.(به x11 نام Xwindows system نیز گفته م‌شود)

                                                    نکته:تمام سیستم عامل ها برای بالا آوردن گرافیک از tcp/ip استفاده میکنند.

                                                    نکته: etc/x11/xorg.conf این فایل قدیمی است و در حال حاضر در هیچ سیستمی (فقط در سیستم‌های قدیم موجود است) یافت نمیشود.



                                                    برای نمایش اطلاعات XServer از دستور زیراستقاده نمایید

                                                    xwininfo

                                                    این دستور ویژگی‌ها و اطلاعات X را نشان میدهد که با زدن آن سیستم منتظر می‌شود تا با موس روی screens کلیک کنیم و سپس اطلاعات آن صفحه نمایش را نشان بدهد.
                                                    خروجی:

                                                    xwininfo: Please select the window about which you

                                                    would like information by clicking the

                                                    mouse in that window

                                                    با کلیک روی یک صفحه نمایش(screens) خروجی زیر نمایش می‌شود:
                                                    xwininfo: Window id: 0x3400026 "Guake!"
                                                    Absolute upper-left X:  0
                                                      Absolute upper-left Y:  25
                                                      Relative upper-left X:  0
                                                      Relative upper-left Y:  0
                                                      Width: 1024
                                                      Height: 405
                                                      Depth: 32
                                                      Visual: 0x9d
                                                      Visual Class: TrueColor
                                                      Border width: 0
                                                      Class: InputOutput
                                                      Colormap: 0x3400003 (not installed)
                                                      Bit Gravity State: NorthWestGravity
                                                      Window Gravity State: NorthWestGravity
                                                      Backing Store State: NotUseful
                                                      Save Under State: no
                                                      Map State: IsViewable
                                                      Override Redirect State: no
                                                      Corners:  +0+25  -0+25  -0-338  +0-338
                                                      -geometry 1024x405+0+25


                                                    نمایش اطلاعات جامع از X11
                                                    xdpyinfo


                                                    • behrooz mohamadi nsasab
                                                    ۲۷
                                                    شهریور

                                                    ابتدا از دستور زیر برای نمایش هارد و پارتیشن‌های موجود استفاده نمایید

                                                    ls

                                                    نکته: شماره گذاری پارتیشن‌ها از صفر (0) شروع می‌شود.

                                                    دستور زیر را به ترتیب از اول تا آخر برای تمامی پارتیشن‌ها امتحان میکنیم، تا زمانی که به پارتیشنی برسیم که فایل سیستم آن ext2 باشد

                                                    ls (hd*,partition_lable*)

                                                    پس از پیدا شدن پارتیش دستور زیر را برای آن می‌زنیم:

                                                    set boot=(hd*,partition_lable*)

                                                    set prefix=(hd*,partition_lable*)/boot/grub

                                                    و در آخر دستور زیر را بزنید:

                                                    insmod normal

                                                    normal

                                                    • behrooz mohamadi nsasab
                                                    ۲۷
                                                    شهریور

                                                    در صفحه ای که گراب ظاهر شده است دکمه e (به معنی رفتن به محیط ادیت و تنظیمات گراب) را بزنید:عبارت زیر را

                                                    init=/boot/bash

                                                    به انتهای خطی که با عبارت زیر شروع می‌شود بیافزایید:

                                                    linux /boot/vmlinuz . . .

                                                    و سپس دکمه های ctrl+X رابزنید:

                                                    مشاهده خواهید کرد که سل بایلا آمده است ولی با این تفاوت که FileSystem از نوع readoly است !

                                                    برای خارج شدن سیستم عامل از readOnly دستور زیر را بزنید:

                                                    mount -rw -o remount /

                                                    حال سیستم عامل حالت rw داشته و میتوان پسورد را تغییر داد (یوزر فعلی ترمینال بالا آمده ،‌ بوزر روت است)

                                                    برای تغییر پسورد دستورزیر را وارد نمایید:

                                                    passwd root

                                                    • behrooz mohamadi nsasab
                                                    ۲۵
                                                    شهریور

                                                    با استفاده از این دستور می توان دریافت که فایل اجرایی یک برنامه ( execute ) برای اجرا به چه کتابخانه (ها) ای وابسطه است.
                                                    برای دیدن وابستگی برنامه ی ls که به چه کتابخانه‌هایی وابستگی دارد،  ابتدا مسیر اجرایی را پیدا نموده و سپس با ldd توابع را جستجو میکنیم.

                                                    # which ls

                                                    خروجی دستور:

                                                    # /bin/ls

                                                    سپس دستور را به ldd میدهیم

                                                    # ldd /bin/ls

                                                    برای راحتی می توان به صورت زیر عمل کرد(خلاصه سازی دو مرحله در یک مرحله)

                                                    # ldd `which ls`

                                                    در مثال بالا ابتدا دستور داخل ‘` اجرا شده سپس خروجی آن دقیقا در جلوی دستور ldd قرار می گیرد.


                                                    نکته: دقیقا همین کار را برنامه ی xargs نیز انجام می دهد با این تفاوت که xargs خروجی دستور قبل را وارد ورودی دستور بعد می کند اما این روش دقیقا خروجی را در جلوی دستور ldd قرار می‌دهد


                                                    نکته: اگر از چند برنامه ldd بگیرید خواهید دید که یک خروجی در همه ی آن ها یکی است(مثلا مطابق زیر)

                                                    .../lib64/ld-linux-x86-64.so.2


                                                    نکته:برنامه whereis نیز همانند which عمل میکند



                                                    نمایش تمام توابع کتابخانه ای dynamic برای اجرای دستور ls

                                                    >> ldd     /bin/ls



                                                    جستجوی تمام مسیرهایی که دارای تابع کتابخانه ای هستند و ذخیره آدرس ونام آنها در فایل

                                                    /etc/ld.so.cache

                                                    و در ادامه

                                                    >> ldconfig



                                                    تمام Library ها در این فایل هستند

                                                    # /etc/ld.so.cache    




                                                    • behrooz mohamadi nsasab
                                                    ۲۵
                                                    شهریور

                                                    زمانی که برنامه ای به اجرا در آورده میشود (مثلا برنامه ی ls), این برنامه برای اجرا به یک سری کتابخانه نیازمند است و باید این کتابخانه ها در داخل ram قرار بگیرد.

                                                    ابزارهایی هستند که این کار را انجام می دهند. به عنوان مثال در هنگام اجرای دستور ls ابتدا چک می‌شود که دستور به چه کتابخانه هایی احتیاج دارد و از بین این کتابخانه ها کدامیک در حال حاضر در داخل ram نیست، پس آن را به داخل ram برده و در نتیجه دستور ls به درستی کار خواهد کرد.

                                                    این ابزار linker نام دارد.

                                                    در یک سیستم عامل تعداد زیادی کتابخانه وجود دارد و linker نمی تواند هر بار برای اجرای هر برنامه, تمامی مسیر های کتابخانه ها را به صورت آنلاین بگردد لذا از دیتابیسی استفاده می کند که در آن , آدرس دقیق هر کتابخانه نوشته شده است . پس زمانی که linker به کتابخانه ای احتیاج داشته باشد ابتدا در دیتابیس خود به دنبال نام آن گشته سپس مسیر آن را از داخل db می خواند و در آخر آن را در داخل ram قرار می‌دهد.
                                                    این دیتابیس را می توان در دو فایل زیر دید که اولی یک فایل متنی و دومی یک فایل باینری است

                                                    /etc/ld.so.conf
                                                    /dtc/ld.so.cache

                                                    بصورت پیش فرض در داخل این دیتابیس،بسیاری مسیر و کتابخانه وجود دارد و حتی ممکن است کتابخانه‌ای جدید بصورت دستی به این دیتابیس اضافه بشود. برای این منظور ابتدا مسیر کتابخانه های خود را در فایل متنی

                                                    ld.so.conf

                                                    اضافه می کنیم سپس با استفاده از دستوری دیگر به نام

                                                    ldconfig

                                                    ایندکس کتابخانه‌های جدید (موجود در مسیری که اضافه کردیم) را به دیتابیس اضافه می کنیم

                                                    /etc/ld.so.cache
                                                    ldconfig

                                                    توجه داشته باشید که برای اضافه کردن کتابخانه به فایل باینری ls.so.cache نیاز به یوزر root است


                                                    Static library
                                                    تمام توابع مورد نیاز همواره باید همراه برنامه باشد، حجم برنامه خیلی بزرگ خواهد شد


                                                    Dynamic Library
                                                    برنامه ها فقط در هنگام نیاز توابع کتابخانه را برای سیستم عامل فراخوانی میکنند و نیاز نیست همه آنها در هر لحظه فراخوانی بشود، اگر نیاز به یک تابع کتابخانه ای که در سیتم عامل نیست پیش آید، در این صورت از اینترنت آن را دانلود خواهد کرد.
                                                    توابع در مسیر زیر هستند

                                                    /lib
                                                    /usr/lib
                                                    /lib64

                                                    • behrooz mohamadi nsasab
                                                    ۲۴
                                                    شهریور

                                                    نگهداری مکانهایی که قابل استفاده اند و انتخاب پیشفرض آن‌ها

                                                    sudo dpkg-reconfigure locales

                                                    دستور زیر متغیرهای مکانی(برنامه ها متغیرهای خود را بر اساس چه کشوری تنظیم نمایند) را نمایش میدهد:
                                                    locale
                                                    خروجی:
                                                    LANG=en_US.utf8
                                                    LANGUAGE=
                                                    LC_CTYPE="en_US.utf8"
                                                    LC_NUMERIC="en_US.utf8"
                                                    LC_TIME="en_US.utf8"
                                                    LC_COLLATE="en_US.utf8"
                                                    LC_MONETARY="en_US.utf8"
                                                    LC_MESSAGES="en_US.utf8"
                                                    LC_PAPER="en_US.utf8"
                                                    LC_NAME="en_US.utf8"
                                                    LC_ADDRESS="en_US.utf8"
                                                    LC_TELEPHONE="en_US.utf8"
                                                    LC_MEASUREMENT="en_US.utf8"
                                                    LC_IDENTIFICATION="en_US.utf8"
                                                    LC_ALL=

                                                    بعنوان مثال LANG=en_US.UTF-8 نشان دهنده آن است که زبان سیستم روی انگلیسی به زبن آمریکا تنظیم شده است و همچنین فرم آن از utf8 پیروی میکند. همچنین موارد دیگر نشان دهنده نوع نمایش اطلاعات سیستم شما در خروجی است مثلاً زمان با رمت انگلیسی یا فارسی نمایش بشود

                                                    :

                                                    انگلیسی: LC_TIME=en_US.UTF-8

                                                    فارسی:LC_TIME=fa_IR



                                                    نکته:می‌توان با LC_ALL تمام موارد local را تغییر داد(با گذاشتن عبارت زیر در فایل etc/profile)

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

                                                    export LC_ALL=fa_IR.UTF-8

                                                    برای برگرداندن به حالت قبل:

                                                    unset  LC_ALL

                                                    برای برگرداندن به حالت defaults

                                                    export LC_ALL=C

                                                    • behrooz mohamadi nsasab
                                                    ۲۴
                                                    شهریور

                                                    Timedatectl

                                                    بهترین دستور برای کنترل و بررسی سیستم دستور زیر است:
                                                    timedatectl
                                                    درخروجی این دستور عبارت real time clock یا RTC همان chip درون مادربرد هست که با خاموش شدن کامپیوتر مقدار ساعت را در خود ذخیره و نگهداری می‌کند
                                                    در خروجی این دستور عبارت DST یا daylight saving time همان مقدار یک ساعتی هست که در تابستان ساعت ها را به جلو و در زمستان ساعت ها را به عقب می‌کشانند
                                                     
                                                    دستورات مفید:
                                                    timedatectl set-time 'YYYY-MM-DD HH:MM:SS'		#set time and date
                                                    timedatectl set-time HH:MM:SS				#for time only
                                                    timedatectl set-time YYYY-MM-DD				#for date only
                                                    timedatectl list-timezones				#list the available timezones
                                                    timedatectl set-timezone "Asia/Tehran" 			#Set timeZone
                                                    timedatectl set-timezone utc				#Set timeZone To UTC
                                                    timedatectl | grep local				#Find out if your hardware clock is set to local timezone-BestMode is "no"
                                                    timedatectl set-local-rtc 1				#Set hardware clock to local timezone
                                                    timedatectl set-local-rtc 0				#Set hardware clock to coordinated universal time (UTC)
                                                    timedatectl set-ntp true				#start automatic time synchronization with remote NTP server,
                                                    timedatectl set-ntp false				#disable NTP time synchronization
                                                    
                                                     
                                                     
                                                     
                                                    sudo dpkg-reconfigure tzdata				#debian: reconfig timerzone
                                                    cat /etc/timezone					#show current timezone
                                                    ls -ltrh /etc/localtime					#show current timezone[lrwxrwxrwx 1 root root 31 اوت   21 23:40 /etc/localtime -> /usr/share/zoneinfo/Asia/Tehran]
                                                    date							#Show time
                                                    date +%Y%m%d-%H%M%S					#Out: 20190707-134444

                                                     

                                                     

                                                    1-hwclock -s [or --hctosys]         #تنظیم ساعت سیستم‌عامل از سخت‌افزار
                                                    2-hwclock -w [or --systohc]         #تنظیم ساعت سخت‌افزار از سیستم‌عامل
                                                    3-hwclock -r [or --show] [or get]   #نمایش ساعت فعلی سخت‌افزار
                                                    

                                                     

                                                    timedatectl set-time 'YYYY-MM-DD HH:MM:SS'
                                                    [or]
                                                    date --set 2020-07-19
                                                    date --set 09:23:14
                                                    hwclock -r
                                                    hwclock -w
                                                    date && hwclock -r
                                                    

                                                     

                                                     

                                                     

                                                    • behrooz mohamadi nsasab
                                                    ۲۴
                                                    شهریور
                                                    مدت زمانی که یک برنامه یا پردازه طول میکشد:
                                                    time cp مبدأ    مقصد


                                                    • behrooz mohamadi nsasab
                                                    ۲۴
                                                    شهریور
                                                    نمایش تقویم (ماه کنونی)
                                                    cal

                                                    نمایش سه ماه قبل , جاری , و بعد
                                                    cal -3

                                                    نمایش 12 ماه سال جاری
                                                    cal -y

                                                    نمایش 12 ماه سال مورد نظر
                                                    cal 2005

                                                    نمایش تقویم فارسی (باید قبلاً نصب کنیم تا دستور اجرا شود)
                                                    jcal

                                                    نمایش سه ماه از تقویم فارسی(ماه قبل و ماه بعد)
                                                    jcal -3


                                                    • behrooz mohamadi nsasab
                                                    ۲۴
                                                    شهریور

                                                    برای تعیین سطح دسترسی، اجازه داشتن و یا اجازه نداشتن، از فایل های زیر استفاده نمایید:

                                                    /etc/cron.allow

                                                    /etc/cron.deny

                                                    و نیز:

                                                    /etc/at.allow

                                                    /etc/at.deny

                                                    برای تعیین مجوز این فایل‌ها را بسازید.(پیشفرض وجود ندارند)

                                                    Allow:ONLY users mentioned in this file are allowed to run this service. All other users will be denied
                                                    Deny: Everybody can use the service except the users mentione


                                                    • behrooz mohamadi nsasab
                                                    ۲۴
                                                    شهریور

                                                    گاهی پیش می‌آید که یک یوزر بنا بر نیاز، دستور را با مالکیت یوزر خود اجرا نماید.

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


                                                    ۱− باید در داخل یوزر خود لاگین نموده و از دستور زیر برای زمان گذاری اقدام نماید

                                                    crontab -e

                                                    ۲− فایل زیر را با یک ادیتور باز کرده

                                                    vim /etc/crontab

                                                    و با فرمت زیر

                                                    m  h  dom mon dow  USER    command and arguments

                                                    برای زمان گذاری اقدام نماید


                                                    ۳− در مسیر زیر

                                                    /etc/cron.d/

                                                    یک فایل ایجاد کرده و با فرمت

                                                    m  h  dom mon dow  USER    command and arguments

                                                    برای زمان گذاری اقدام نماید


                                                    ۴−

                                                    • behrooz mohamadi nsasab
                                                    ۲۴
                                                    شهریور

                                                    اجرای یک دستور تنها یکبار

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

                                                    at now + 1 min


                                                    برنامه‌ریزی یک دستور در روز بعد در زمان اکنون

                                                    at tomorrow


                                                    نکته:باید برای خروج ctrl+d رابفشرید

                                                    نکته:دستورات در شل بنام sh اجرا خواهند شدیعنیbin/sh/
                                                    مشاهده تمام کارهای موجود در صف انتظار

                                                    atq


                                                    حذف یک کار موجود در صف انتظار برحسب شماره آن

                                                    atrm 3

                                                    • behrooz mohamadi nsasab
                                                    ۲۴
                                                    شهریور


                                                    تفاوت cron و anacron در این است که اگر کاری در cron تعریف شود درصورت خاموش بودن سیستم، آن کار منقضی می‌شود و دیگر اجرا نخواهد شد. اما در anacron  مکانیزم بدین صورت است که حتس در صورت خاموش بودن سیستم عامل، کار مورد نظر پس از روشن شدن انجام خواهد شد.

                                                    معمولا برای تهیه فایل پشتیبانی یا backup از این مورد استفاده می‌شود .


                                                    /etc /anacrontab

                                                    • behrooz mohamadi nsasab
                                                    ۲۴
                                                    شهریور

                                                    Minute Hour DayOfMonth Month DayOfWeek Command


                                                    Minute: دقیقه(0-59)

                                                    Hour: ساعت(0-23)

                                                    DayOfMonth: روز از ماه(1-31)

                                                    Month: ماه(1-12 یا نام ماه)

                                                    DayOfWeek: روز از هفته(0-7 یا نام روز )، صفر یعنی یک‌شنبه و برای دیگر روزها به ترتیب از یک‌شنبه محاسبه شود


                                                    نکته: اگر جای یکی از موارد بالا ستاره گذاشته شود یعنی همه (مثلاً دقیقه را ستاره بود یعنی هر دقیقه)

                                                    نکته: اگر بجای زمان در موارد بالا تنها از reboot@ استفاده شود یعنی هربار که سیستم ریست شود کار خاص مورد نظر انجام بشود

                                                    نکته: اگر بجای زمان در موارد بالا تنها از daily@ استفاده شود یعنی هرروز کار خاص مورد نظر انجام بشود

                                                    نکته: وقتی دستوری در cron اجرا میشودخروجی آن دستور به owner آن cron ایمیل خواهد شد

                                                    نکته:cron یک سرویس است.

                                                    نکته: با افزودن یک job جدید تنظیمات و کارها در مکان زیر قرار می‌گیرند:

                                                    /var/spool/cron/tabs/ or /var/spool/crontabs

                                                    که به هیچ وجه نباید مستقیماً این فایل را ادیت کنیم بلکه باید توسط دستور crontab -e جاب را مدیریت کنیم که باعث بروز رسانیدر این فایل خواهد شد


                                                    مشاهده تمام job های موجود در cron کاربر فعلی

                                                    crontab -l


                                                    برای ادیت کردن و افزودن job  در گستره کاربر فعلی  از دستور زیر استفاه شود:

                                                    crontab -e

                                                    نکته: اگر در مسیرهای زیر  دستوری قرار بگیرد توسط سیستم عامل ضمانت میشود که آن دستور به اجرا در آورده شود(در بازه زمانی مشخص شده در نام آن دایرکتوری).

                                                    /etc/cron.daily:        once on each days

                                                    /etc/cron.hourly :     once on each hours

                                                    /etc/cron.monthly:   once on each month

                                                    /etc/cron.weekly:     once on each week


                                                    نکته: هرچه در داخل دایرکتوری /etc/cron.d/ قرار بگیرد گویی در ادامه فایل etc/crontab/ قرار گرفته است.این مکانیزم برای تمیز ماندن دستورات و فایل‌ها و ایجاد نظم در دادن دستورات متفاوت در فایل های متفاوت بوجود آمده است.مثلا یک فایل بنام raw ایجاد میکنیم و درون آن مانند فرم دستورcron  یک job میسازیم و آن را میبندیم، ازین پس کار آن فایل هم به کارهای سرویس cron افزوده خواهد شد.



                                                    مثال‌ها:

                                                    اجرا دستور در ساعت 14:15  اول هرماه

                                                    15 14 1 * * command


                                                    اجرا دستور در ساعت 22:00 در دوشنبه تا جمعه

                                                    0 22 * * 1-5 command


                                                    اجرا دستور در دقیقه 23 در هر ساعت زوج (دقیقه های 23 در تمام سات های روز ، درحالت هر دوساعت یکبار) در هر ماه از سال(مثلا:00:23 و 02:23 و 04:23 و 06:23 و ...)

                                                    23 0-23/2 * * * command



                                                    اجرا دستور در ساعت 04:05  در روزهای یک‌شنبه در هر ماه از سال

                                                    5 4 * * sun command


                                                    اجرا دستور در هر 5 دقیقه یکبار

                                                    */5 * * * * command


                                                    اجرا دستور در هر 8:42 و 18:42 دقیقه در هر دوشنبه تا جمعه در هر ماه

                                                    42 8,18 * * 1-5 command


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

                                                    @reboot command


                                                    اجرا دستور در هر دقیقه 42 در هر چهارساعت یکبار

                                                    42*/4 * * * command


                                                    اجرا دستور در هر دوروز یکبار در روزهای دوشنبه تا پنج‌شنبه

                                                    * * * * 1-4/2 command


                                                    • behrooz mohamadi nsasab