Difference between revisions of "Perintah Linux S"
Jump to navigation
Jump to search
Gibransyah (talk | contribs) |
Gibransyah (talk | contribs) |
||
(12 intermediate revisions by the same user not shown) | |||
Line 34: | Line 34: | ||
=sdiff= | =sdiff= | ||
=sed= | =sed= | ||
+ | ''stream editor for filtering and transforming text'' | ||
+ | |||
+ | == Sintaksis Sed == | ||
+ | $ sed 'ADDRESSs/REGEXP/REPLACEMENT/FLAGS' nama_berkas | ||
+ | $ sed 'PATTERNs/REGEXP/REPLACEMENT/FLAGS' nama_berkas<br> | ||
+ | # s is substitute command | ||
+ | # / is a delimiter | ||
+ | # REGEXP is regular expression to match | ||
+ | # REPLACEMENT is a value to replace<br> | ||
+ | FLAGS can be any of the following | ||
+ | # g Replace all the instance of REGEXP with REPLACEMENT | ||
+ | # n Could be any number,replace nth instance of the REGEXP with REPLACEMENT. | ||
+ | # p If substitution was made, then prints the new pattern space. | ||
+ | # i match REGEXP in a case-insensitive manner. | ||
+ | # w file If substitution was made, write out the result to the given file. | ||
+ | # We can use different delimiters ( one of @ % ; : ) instead of / | ||
+ | |||
+ | * Tambahkan kata "CASCADE" untuk setiap baris yg diawali oleh kata "DROP" dan diakhiri karakter ";" | ||
+ | ''Isi file <code>drop.sql</code>'' | ||
+ | DROP TABLE petruk_line_produksi; | ||
+ | DROP TABLE petruk_kapasitas_produksi; | ||
+ | DROP TABLE petruk_status_mutasi; | ||
+ | DROP TABLE petruk_statusnc; | ||
+ | CREATE TABLE gareng_stat ....; | ||
+ | DROP TABLE petruk_tindakannc;<br> | ||
+ | $ sed -i '/^DROP/s/;$/ CASCADE;/' mytable.sql<br> | ||
+ | ''Output'' | ||
+ | DROP TABLE petruk_line_produksi CASCADE; | ||
+ | DROP TABLE petruk_kapasitas_produksi CASCADE; | ||
+ | DROP TABLE petruk_status_mutasi CASCADE; | ||
+ | DROP TABLE petruk_statusnc CASCADE; | ||
+ | DROP TABLE petruk_tindakannc CASCADE; | ||
+ | |||
+ | * Cari semua file yang mengandung kata 127.0.0.1 ganti dengan localhost | ||
+ | $ grep -r -i "127.0.0.1" | xargs sed -i 's/127.0.0.1/localhost/g' | ||
+ | |||
=sendmail= | =sendmail= | ||
=sensors= | =sensors= | ||
Line 46: | Line 82: | ||
=sftp= | =sftp= | ||
=sh= | =sh= | ||
+ | |||
+ | =shutdown= | ||
+ | ''restart atau shutdown komputer'' | ||
+ | shutdown -h now ''Mematikan komputer'' | ||
+ | shutdown -r now ''Merestart komputer'' | ||
+ | |||
=sha1sum= | =sha1sum= | ||
=showkey= | =showkey= | ||
Line 61: | Line 103: | ||
=split= | =split= | ||
=ssh= | =ssh= | ||
+ | ''Login ke dalam remote machine'' | ||
+ | * Login ke alamat ip 8.8.8.8 sebagai user petruk | ||
+ | ssh petruk@8.8.8.8 | ||
+ | |||
+ | * Login ke ip 8.8.8.8 sebagai user petruk, setelah login langsung eksekusi perintah di remote host | ||
+ | |||
+ | ssh petruk@8.8.8.8 -v <<'ENDSSH' pg_dump -Fc -U postgres -h localhost punokawan > $(date +%Y%m%d)_production.dump --verbose ENDSSH | ||
+ | |||
=ssh-add= | =ssh-add= | ||
=ssh-agent= | =ssh-agent= | ||
=ssh-keygen= | =ssh-keygen= | ||
+ | authentication key generation, management and conversion | ||
+ | |||
+ | Generate public key untuk disebar ke otentikasi internet | ||
+ | $ ssh-keygen | ||
+ | |||
=ssh-keyscan= | =ssh-keyscan= | ||
=sshd= | =sshd= | ||
Line 75: | Line 130: | ||
=su= | =su= | ||
=sudo= | =sudo= | ||
+ | ''Digunakan agar pengguna biasa dapat menjalakan perintah dengan security privilege milik pengguna lain (biasanya sebagai superuser/root)'' | ||
+ | * Hapus direktori document di <code>/home/alif/document</code> secara rekursif | ||
+ | sudo rm -rf /home/alif/document | ||
+ | * Jalankan perintah terakhir sebagai root | ||
+ | sudo !! | ||
+ | |||
=sum= | =sum= | ||
=swapoff= | =swapoff= |
Latest revision as of 11:18, 25 August 2015
Indeks - A - B - C - D - E - F - G - H - I - J - K - L - M - N - O - P - Q - R - S - T - U - V - W - X - Y - Z
sane-find-scanner
scanadf
scanimage
scp
screen
script
sdiff
sed
stream editor for filtering and transforming text
Sintaksis Sed
$ sed 'ADDRESSs/REGEXP/REPLACEMENT/FLAGS' nama_berkas $ sed 'PATTERNs/REGEXP/REPLACEMENT/FLAGS' nama_berkas
# s is substitute command # / is a delimiter # REGEXP is regular expression to match # REPLACEMENT is a value to replace
FLAGS can be any of the following # g Replace all the instance of REGEXP with REPLACEMENT # n Could be any number,replace nth instance of the REGEXP with REPLACEMENT. # p If substitution was made, then prints the new pattern space. # i match REGEXP in a case-insensitive manner. # w file If substitution was made, write out the result to the given file. # We can use different delimiters ( one of @ % ; : ) instead of /
- Tambahkan kata "CASCADE" untuk setiap baris yg diawali oleh kata "DROP" dan diakhiri karakter ";"
Isi filedrop.sql
DROP TABLE petruk_line_produksi; DROP TABLE petruk_kapasitas_produksi; DROP TABLE petruk_status_mutasi; DROP TABLE petruk_statusnc; CREATE TABLE gareng_stat ....; DROP TABLE petruk_tindakannc;
$ sed -i '/^DROP/s/;$/ CASCADE;/' mytable.sql
Output DROP TABLE petruk_line_produksi CASCADE; DROP TABLE petruk_kapasitas_produksi CASCADE; DROP TABLE petruk_status_mutasi CASCADE; DROP TABLE petruk_statusnc CASCADE; DROP TABLE petruk_tindakannc CASCADE;
- Cari semua file yang mengandung kata 127.0.0.1 ganti dengan localhost
$ grep -r -i "127.0.0.1" | xargs sed -i 's/127.0.0.1/localhost/g'
sendmail
sensors
seq
setfdprm
setkeycodes
setleds
setmetamode
setquota
setsid
setterm
sftp
sh
shutdown
restart atau shutdown komputer
shutdown -h now Mematikan komputer shutdown -r now Merestart komputer
sha1sum
showkey
showmount
shred
shutdown
size
skill
slabtop
slattach
sleep
slocate
snice
sort
split
ssh
Login ke dalam remote machine
- Login ke alamat ip 8.8.8.8 sebagai user petruk
ssh petruk@8.8.8.8
- Login ke ip 8.8.8.8 sebagai user petruk, setelah login langsung eksekusi perintah di remote host
ssh petruk@8.8.8.8 -v <<'ENDSSH' pg_dump -Fc -U postgres -h localhost punokawan > $(date +%Y%m%d)_production.dump --verbose ENDSSH
ssh-add
ssh-agent
ssh-keygen
authentication key generation, management and conversion
Generate public key untuk disebar ke otentikasi internet $ ssh-keygen
ssh-keyscan
sshd
stat
statd
strace
strfile
strings
strip
stty
su
sudo
Digunakan agar pengguna biasa dapat menjalakan perintah dengan security privilege milik pengguna lain (biasanya sebagai superuser/root)
- Hapus direktori document di
/home/alif/document
secara rekursif
sudo rm -rf /home/alif/document
- Jalankan perintah terakhir sebagai root
sudo !!