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)
DISM /Online /Enable-Feature /FeatureName:NetFx3 /All /LimitAccess /Source:d:\sources\sxs
vboxmanage list hostinfo
vboxmanage list vms
vboxmanage list vms --long
vboxmanage list runningvms
vboxmanage list runningvms --long
vboxmanage showvminfo {UUID}
vboxheadless --startvm {UUID}
vboxmanage controlvm {UUID} savestate
vboxmanage controlvm {UUID} acpipowerbutton
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
یک تجربه: در دبیان ۹ برای اینکه 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
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;
در سیستم عامل لینوکس شما قالبیت این را دارید که از محیط گرافیکی دلخواه خود استفاده نمایید: (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.
محیط چهارم کاربری: LXDE
محیط کاربری پنجم(پلاسما): KDE
رفع مشکل 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;
${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.
!!
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.
برای اطلاع پیدا کردن از اطلاعات ساختاری و تعداد کانکشنها و موارد administrator میتونیم ماژول را status_module فعال نمایید
vim httpd.conf
<Location "/server-status">
SetHandler server-status
Require host example.com
</Location>
سپس به آی پی رفته و در ادامه عبارت server-status را تایپ نمایید
اگر بخواهیم تنها عبارات سه حرفی را به نمایش بگذاریم از دستور زیر استفاده میکنیم
grep -x '.\{3,10\}'
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 |
برای نصب برنامه pycharm که یک ادیتور هست که کد پایتون را کامپایل میکند به روش زیر عمل میکنیم(نصب در دبیان9)
نکته: از لینک آخر این دایکومنت برای نصب در توزیعهای دیگر نیز میتوانید استفاده نمایید
گام اول: بارگردن آدرس URL
گام دوم: instal this package
گام سوم: select opration sysstem
گام چهارم: select server to download
گام پنجم:
sudo apt-get install pycharm-community-sloppy
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
در زیر یک نمونه از فایل source.list که از سیستم عامل دبیان ۹ است آورده شده است:
deb http://deb.debian.org/debian stretch main deb-src http://deb.debian.org/debian stretch main deb http://deb.debian.org/debian stretch-updates main deb-src http://deb.debian.org/debian stretch-updates main deb http://security.debian.org/debian-security/ stretch/updates main deb-src http://security.debian.org/debian-security/ stretch/updates main
نکته: اگر بخواهید از بستههای contrib و non-free استفاده نمایید، میتوانید پس از main یک فاصله گذاشته و به ترتیب عبارت contrib و non-free را تایپ نمایید
نکته: اگر بخواهید موارد بالا را به حالت گرافیکی تنظیم نمایید از دستور زیر استفاده نمایید:
sudo gksu --desktop /usr/share/applications/software-properties.desktop /usr/bin/software-properties-gtk
جستجو در عبارت است نظیر grep در لینوکس
ipconfig | findstr IP
تمام اطلاعات از کارت شبکه:
ipconfig /all
DNS های لوکال cache شده در سیستم
ipconfig /displaydns
ipconfig /flushdns
systeminfo
tasklist
بستن یک برنامه بر اساس پروسس آی دی
taskkill /PID NUMBER
نمایش متن یک فایل متنی
type FILE.txt
وضعیت و اطلاعات سوکتها و پورتها و کانکشنهای سیسیتم را نشان میدهد
netstat -a
برای start ویا stop کردن سرویسها از دستور زیر استفاده میشود:
net start SERVICE
net stop SERVICE
برای افزودن یک درارو شبکهای ویا حذف آن از دستور زیر استفاده میشود
net use m: \myserversharename
net use m: \myserversharename /delete
نکته:دستور net بسیار کارهای دیگر نیز میتواتند انجام دهد که شرح آن را در help آن مشاهده نمایید.
برای اینکه ببینید dns پیش فرض شما چه میباشد از دستور nslookup استفاده نمایید
nslookup
برای تغییر dns از پیشفرض به یک سرور دیگر ابتدا دستور nslookup را زده و سپس دستور set ds وارد کرده و اینتر را بزنید و سپس آدرس ip دی ان اس سرور مورد نظر را وارد نمایید.
nslookup
set ds
8.8.8.8
nslookup NAME 8.8.8.8.
ترتیب خوانده شدن فایل های کانفیگی در دبیان 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 (اجرا در ششمین مرحله)
/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 |
--------------e---- 970107.txt
$ echo salam >> /tmp/970107.txt salam
$ sudo chattr +i /tmp/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
--------------e---- /tmp/970107.txt
-------------------------------------------------------------------------------
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
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
لینک های مفید: URL
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 -;}
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
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
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
directory_to_share client(share_option1,.,share_optionN)7- sudo exportfs -a
اگر در ویندوز پسورد خود را فراموش کردید برای ورود به سیستم میتوان به روش زیر عمل کرد:
برای ارسال ایمیل از از طریق ترمینال باید با دستور زیر بسته های ذیل را نصب نمایید:
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
بهترین راه خاموش کردن سرورهای لینوکس است، زیرا به تمام کاربران Login شده سرور اطلاع رسانی مینماید (ارسال و نمایش پیغام)
همچنین از Login کاربر جدید جلوگیری به عمل آورده و سیگنالی به init ارسال مینماید تا Run Level تغییر نماید و پس از آن سیگنال دیگری ( سیگنالSIGTERM ) به تمامی Process های Run شده روی سرور ارسال مینماید که توسط آن مهلت چند ثانیه ای ذخیره اطلاعات Save نشده و آماده سازی برایkill شدن به پردازش ها میدهد
در نهایت پس از گذشت مدت زمان مهلت داده شده، در صورتی که هنوز پردازشی باقی مانده باشند، سیگنال kill شدن بصورت Force به آن ارسال میشود (سیگنال SIGKILL ) و در این حالت سیستم خاموش خواهد شد.
Switch ها:
خاموش شدن سیستم بعد از وقفه کوتاه
# 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
با استفاده از دستور 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
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 منحصر بفرد خود وارد عمل شود.
ابتدا از دستور زیر برای نمایش هارد و پارتیشنهای موجود استفاده نمایید
ls
نکته: شماره گذاری پارتیشنها از صفر (0) شروع میشود.
دستور زیر را به ترتیب از اول تا آخر برای تمامی پارتیشنها امتحان میکنیم، تا زمانی که به پارتیشنی برسیم که فایل سیستم آن ext2 باشد
ls (hd*,partition_lable*)
پس از پیدا شدن پارتیش دستور زیر را برای آن میزنیم:
set boot=(hd*,partition_lable*)
set prefix=(hd*,partition_lable*)/boot/grub
و در آخر دستور زیر را بزنید:
insmod normal
normal
در صفحه ای که گراب ظاهر شده است دکمه e (به معنی رفتن به محیط ادیت و تنظیمات گراب) را بزنید:عبارت زیر را
init=/boot/bash
به انتهای خطی که با عبارت زیر شروع میشود بیافزایید:
linux /boot/vmlinuz . . .
و سپس دکمه های ctrl+X رابزنید:
مشاهده خواهید کرد که سل بایلا آمده است ولی با این تفاوت که FileSystem از نوع readoly است !
برای خارج شدن سیستم عامل از readOnly دستور زیر را بزنید:
mount -rw -o remount /
حال سیستم عامل حالت rw داشته و میتوان پسورد را تغییر داد (یوزر فعلی ترمینال بالا آمده ، بوزر روت است)
برای تغییر پسورد دستورزیر را وارد نمایید:
passwd root
زمانی که برنامه ای به اجرا در آورده میشود (مثلا برنامه ی 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
timedatectl
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
برای تعیین سطح دسترسی، اجازه داشتن و یا اجازه نداشتن، از فایل های زیر استفاده نمایید:
/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
گاهی پیش میآید که یک یوزر بنا بر نیاز، دستور را با مالکیت یوزر خود اجرا نماید.
در این صورت باید با یکی از روش های زیر عمل نماید:
۱− باید در داخل یوزر خود لاگین نموده و از دستور زیر برای زمان گذاری اقدام نماید
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
برای زمان گذاری اقدام نماید
۴−
اجرای یک دستور تنها یکبار
برنامهریزی یک دستور در یک دقیقه بعد
at now + 1 min
برنامهریزی یک دستور در روز بعد در زمان اکنون
at tomorrow
نکته:باید برای خروج ctrl+d رابفشرید
نکته:دستورات در شل بنام sh اجرا خواهند شدیعنیbin/sh/
مشاهده تمام کارهای موجود در صف انتظار
atq
حذف یک کار موجود در صف انتظار برحسب شماره آن
atrm 3
در آموزش زیر :
آدرس شبکه :10.0.20.0/24
نام دامنه: MyDomain.it
سرور دی ان اس: 10.0.20.240
سرورد دی ان اس برای فوروارد:192.168.100.12
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; }; };
zone "MyDomain.it" IN { type master; file "MyDomain.it"; };
$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
# rndc querylog on
$ sudo named-checkconf
# /usr/sbin/named-checkzone my.net /var/cache/bind/my.net.zone
$ sudo systemctl enable bind9 $ sudo systemctl start bind9
ماژول 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 استفاده کرد
درباره این سایت