25
List of debian Commands: poweroff how copy files: check note>>> date cd (path) passwd deluser [options] [--remove-home] [--home DIR] [--remove-all-files] [--backup] cat /etc/passwd | cut -d: -f1 cat /etc/group |cut -d: -f1 All users management commands in notes Ctrl+ z Ctrl+ c fg bg 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 # touch file_name << command is the easiest way to create ne * To find a word in VI / Vim, just type "/" or "?", followe

List of important debian Commands.xlsx

Embed Size (px)

Citation preview

Page 1: List of important debian Commands.xlsx

List of debian Commands:

poweroff

how copy files: check note>>>

date

cd (path)

passwddeluser [options] [--remove-home] [--home DIR] [--remove-all-files] [--backup] [--backup-to] user

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

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

All users management commands in notes

Ctrl+ z

Ctrl+ c

fg

bg

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

# touch file_name << command is the easiest way to create new, empty files

* To find a word in VI / Vim, just type "/" or "?", followed by the word you're searching for. Then enter. To go next press "n".

A4
Author: source: http://www.computerhope.com/unix/ucp.htm Syntax cp [OPTION]... SOURCE DEST cp [OPTION]... SOURCE... DIRECTORY cp [OPTION]... --target-directory=DIRECTORY SOURCE... -a, --archive same as -dpR --backup[=CONTROL] make a backup of each existing destination file -b like --backup but does not accept an argument --copy-contents copy contents of special files when recursive -d same as --no-dereference --preserve=link --no-dereference never follow symbolic links -f, --force if an existing destination file cannot be opened, remove it and try again -i, --interactive prompt before overwrite -H follow command-line symbolic links -l, --link link files instead of copying -L, --dereference always follow symbolic links -p same as --preserve=mode,ownership,timestamps --preserve[=ATTR_LIST] preserve the specified attributes (default: mode,ownership,timestamps), if possible additional attributes: links, all --no-preserve=ATTR_LIST don't preserve the specified attributes --parents append source path to DIRECTORY -P same as '--no-dereference' -R, -r, --recursive copy directories recursively --remove-destination remove each existing destination file before attempting to open it (contrast with --force) --reply={yes,no,query} specify how to handle the prompt about an existing destination file --sparse=WHEN control creation of sparse files --strip-trailing-slashes remove any trailing slashes from each SOURCE argument -s, --symbolic-link make symbolic links instead of copying -S, --suffix=SUFFIX override the usual backup suffix --target-directory=DIRECTORY move all SOURCE arguments into DIRECTORY -u, --update copy only when the SOURCE file is newer than the destination file or when the destination file is missing -v, --verbose explain what is being done -x, --one-file-system stay on this file system Examples cp file1.txt newdir Copies the file1.txt in the current directory to the newdir directory. cp /home/public_html/mylog.txt /home/public_html/backup/mylog.bak Copies the mylog.txt file in the public_html directory into the public_html/backup directory as mylog.bak. The files are identical however have different names. cp *.txt newdir Copy all files ending in .txt into the newdir directory. cp -r /home/hope/files/* /home/hope/backup Copies all the files, directories, and subdirectories in the files directory into the backup directory. yes | cp /home/hope/files/* /home/hope/files2 Copies all the files and subdirectories in files into the files2 directory. If files with the same name exist or it's prompted to overwrite the file it answers yes. Additional information Many new versions of Linux/Unix or their variants may also be able to use copy in place of cp or have an alias setup for cp as copy.
A8
Author: source: http://www.debianadmin.com/manpages/user/delusermanpage.htm NAME deluser, delgroup - remove a user or group from the system SYNOPSIS deluser [options] [--remove-home] [--home DIR] [--remove-all-files] [--backup] [--backup-to] user deluser --group [options] group delgroup [options] [--only-if-empty] group deluser [options] user group COMMON OPTIONS [--quiet] [--system] [--help] [--version] [--conf FILE] DESCRIPTION deluser and delgroup remove users and groups from the system according to command line options and configuration information in /etc/deluser.conf and /etc/adduser.conf. They are friendlier front ends to the userdel and groupdel programs, removing the home directory as option or even all files on the system owned by the user to be removed, running a custom script, and other features. deluser and delgroup can be run in one of three modes: Remove a normal user If called with one non-option argument and without the --group option, deluser will remove a normal user. By default, deluser will remove the user without removing the home directory, the mail spool or any other files on the system owned by the user. Removing the home directory and mail spool can be achieved using the --remove-home option. If the --home option is given, deluser will only remove the user if the directory given to the --home option matches the user's real home directory. The --remove-all-files option removes all files on the system owned by the user. Note that if you activate both options --remove-home will have no effect because all files including the home directory and mail spool are already covered by the --remove-all-files option. If you want to backup all files before deleting them you can activate the --backup option which will create a file username.tar(.gz|.bz2) in the directory specified by the --backup-to option (defaulting to the current working directory). Both the remove and backup options can also be acti- vated for default in the configuration file /etc/deluser.conf. See deluser.conf(5) for details. If the file /usr/local/sbin/deluser.local exists, it will be executed after the user account has been removed in order to do any local setup. The arguments passed to deluser.local are: username uid gid home-directory Remove a group If deluser is called with the --group option, or delgroup is called, a group will be removed. Warning: If any users have the group to be removed as primary group the group cannot be removed. If the option --only-if-empty is given, the group won't be removed if it has any members left. Remove an user from a specific group If called with two non-option arguments, deluser will remove an user from a specific group. OPTIONS --conf FILE Use FILE instead of /etc/deluser.conf. --group Remove a group. This is the default action if the program is invoked as delgroup. --help Display brief instructions. --quiet Suppress progress messages. --system Only delete if user/group is a system user/group. This avoids accidentally deleting non-system user/groups. Additionally, if the user does not exist, no error value is returned. This option is mainly for use in Debian package maintainer scripts. --version Display version and copyright information. FILES /etc/deluser.conf
A11
Author: source: http://www.debianadmin.com/users-and-groups-administration-in-linux.html The user information is stored in the system /etc/passwd and /etc/shadow files, and that additionally, group membership information is stored in the /etc/group file. The update-passwd tool keeps the entries in these master files in sync on all Debian systems.While it is possible to edit these files by hand, it is not recommended.There exist several command line tools, which can be used to manage these files instead. Now we are going to see the complete users and groups administration commands with examples and man pages. Users Administration in Linux Add New User in Linux useradd -- Create a new user or update default new user information Syntax useradd [-c comment] [-d home_dir] [-e expire_date] [-f inactive_days] [-g initial_group] [-G group[,...]] [-m [-k skeleton_dir]] [-o] [-p passwd] [-s shell] [-u uid] login useradd -D [-g default_group] [-b default_home] [-e default_expire_date] [-f default_inactive] [-s default_shell] If you want to know more available options you need to check the useradd man page Examples Adding New User First you need to create three (test1,test2,admin1) groups for our examples using groupadd Options -d home directory -s starting program (shell) -p password -g (primary group assigned to the users) -G (Other groups the user belongs to) -m (Create the user's home directory ) To add a new user with a primary group of test1 a second group test2 starting shell /bin/bash password of xxxx home directory of admin create home directory a login name of admin #useradd -g test1 -G test2 -s /bin/bash -p xxxx -d/home/admin -m admin This will create a new user admin. One additional switch worth mentioning is "-D", which controls the defaults for useradd. Specifying the "-D" switch on its own will simply display the default settings, while specifying -D in conjunction with other switches will change the defaults to those values. # useradd -D GROUP=100 INACTIVE=-1HOME=/home INACTIVE=-1 EXPIRE= SHELL=/bin/bash SKEL=/etc/skel # useradd -D -s /bin/sh # useradd -D GROUP=100 HOME=/home INACTIVE=-1 EXPIRE= SHELL=/bin/sh SKEL=/etc/skel As you can see, this changes the default shell for created users from "bash" to "sh". adduser -- User Friendly Frontend for useradd command Syntax adduser [options] user group If you want to know available option refer add user man page Example #adduser admin Adding user `admin' ... Adding new group `admin' (1001) ... Adding new user `admin' (1001) with group `admin' ... Creating home directory `/home/admin' ... Copying files from `/etc/skel' ... Enter new UNIX password: Retype new UNIX password: passwd: password updated successfully Changing the user information for admin Enter the new value, or press ENTER for the default Full Name []: Admin Room Number []: Work Phone []: Home Phone []: Other []: Is the information correct? [y/N] y You'll notice that, by default, the adduser command creates a group with the same name as the username, and makes this group the primary group for that user. This is called a user private group (UPG) Modify User in Linux usermod -- Modify a user account Syntax usermod [-c comment] [-d home_dir [-m]] [-e expire_date] [-f inactive_days] [-g initial_group] [-G group [,...]] [-l login_name] [-p passwd] [-s shell] [-u uid [-o]] [-L|-U] login If you want to know available option check usermod man page Example Options: -d home directory -s starting program (shell) -p password -g (primary group assigned to the users) -G (Other groups the user belongs to) To add the group ‘others' to the user admin #usermod -G others admin Delete User in Linux userdel -- Delete a user account and related files Syntax userdel [-r] login If you want to know available options check userdel man page Example Options -r (remove home directory) To remove the user ‘admin' and his home directory #userdel -r admin deluser -- remove a user from the system Syntax deluser [options] user group If you want more options check deluser man page Example By default, deluser will remove the user without removing the home directory, the mail spool or any other files on the system owned by the user. Removing the home directory and mail spool can be achieved using the --remove-home option. If the --home option is given, deluser will only remove the user if the directory given to the --home option matches the user's real home directory. #deluser --remove-home admin Groups Administration in Linux Add New Group in Linux groupadd -- Create a new group Syntax groupadd [-g gid [-o]] group For more options check groupadd man page Example #groupadd test1 This will create a test1 group addgroup -- add a group to the system Syntax addgroup [options] [--gid ID] group If you want to know available options check addgroup man page #addgroup Enter a groupname to add: admin1 Adding group `admin1′ (1001)... Done. Modify Group in Linux groupmod -- Modify a group Syntax groupmod [-g gid [-o]] [-n group_name ] group For more options check groupmod man page Example #groupmod test1 test2 This will modify group name test1 to test2 Delete group in Linux groupdel -- Delete a group Syntax groupdel groupname For more options check groupdel man page Example #groupdel test2 this will delete the test2 group delgroup -- remove a group from the system Syntax delgroup [options] [--only-if-empty] group For more details about options check delgroup man page Example #delgroup --only-if-empty test2 Removing group `test2′... done. groups Command print the groups a user is in Syntax groups [username] This simple command displays what groups a user is a member of. It takes the username of user as a parameter. If no username is given, it defaults to the current user. # groups root # groups admin test1 : test2
A20
Author: source: http://www.computerhope.com/unix/uls.htm
A25
Author: http://www.cyberciti.biz/faq/vi-show-line-numbers/
Page 2: List of important debian Commands.xlsx

* Another feature is to launch a search on the word where the cursor is positioned. Place the cursor over the word to search for, then press * or # to to look it up.

sudo service nginx "argumnet"

nginx -t

what I used to change user name with keeping his groups and move his home folder:

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 but the new user home folder was moved into the root since I was logged as him since I didn't specify the new folder path..

rm or unlink <link name>

usermod -g <NewPrimaryGroupName> <CurrentUserName>

dpkg --get-selections|grep <app name> >> then use apt-get purge <pkg1> <pkg2>..etc

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 select whole lines, or Ctrl-v for a vertical block).Move the cursor to the end of the text to be cut/copied. (While selecting text, you can perform searches and other advanced movement, a feature that sets vim apart from most other editors.)Press d (as in "delete") to cut, or y (as in "yank", which I imagine meaning "yank so hard and fast that it leaves a copy behind") to copy.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 using a mouse or similar pointing device, although I strongly prefer to navigate using the keyboard.

Bonus tip: To replace the selected text with new text (to be entered by you), press 'c' instead of 'd' or 'y' on step 4. This deletes the selection and leaves you in insert mode. Then, instead of (or prior to) steps 5-6, type your replacement text.

usermod -m -d /path/to/new/home/dir userNameHere

A30
Author: http://vim.wikia.com/wiki/VimTip386
A35
Author: sourec: http://linux.die.net/man/8/usermod usermod(8) - Linux man page Name usermod - modify a user account Synopsis usermod [options] LOGIN Description The usermod command modifies the system account files to reflect the changes that are specified on the command line. Options The options which apply to the usermod command are: -a, --append Add the user to the supplementary group(s). Use only with the -G option. -c, --comment COMMENT The new value of the user's password file comment field. It is normally modified using the chfn(1) utility. -d, --home HOME_DIR The user's new login directory. If the -m option is given, the contents of the current home directory will be moved to the new home directory, which is created if it does not already exist. -e, --expiredate EXPIRE_DATE The date on which the user account will be disabled. The date is specified in the format YYYY-MM-DD. -f, --inactive INACTIVE The number of days after a password expires until the account is permanently disabled. A value of 0 disables the account as soon as the password has expired, and a value of -1 disables the feature. -g, --gid GROUP The group name or number of the user's new initial login group. The group must exist. -G, --groups GROUP1[,GROUP2,...[,GROUPN]]] A list of supplementary groups which the user is also a member of. Each group is separated from the next by a comma, with no intervening whitespace. The groups are subject to the same restrictions as the group given with the -g option. If the user is currently a member of a group which is not listed, the user will be removed from the group. This behaviour can be changed via the -a option, which appends the user to the current supplementary group list. -l, --login NEW_LOGIN The name of the user will be changed from LOGIN to NEW_LOGIN. Nothing else is changed. In particular, the user's home directory name should probably be changed manually to reflect the new login name. -L, --lock Lock a user's password. This puts a '!' in front of the encrypted password, effectively disabling the password. You can't use this option with -p or -U. Note: if you wish to lock the account (not only access with a password), you should also set the EXPIRE_DATE to 1. -m, --move-home Move the content of the user's home directory to the new location. This option is only valid in combination with the -d (or --home) option. -o, --non-unique When used with the -u option, this option allows to change the user ID to a non-unique value. -p, --password PASSWORD The encrypted password, as returned by crypt(3). Note: This option is not recommended because the password (or encrypted password) will be visible by users listing the processes. You should make sure the password respects the system's password policy. -s, --shell SHELL The name of the user's new login shell. Setting this field to blank causes the system to select the default login shell. -u, --uid UID The new numerical value of the user's ID. This value must be unique, unless the -o option is used. The value must be non-negative. Values between 0 and 999 are typically reserved for system accounts. The user's mailbox, and any files which the user owns and which are located in the user's home directory will have the file user ID changed automatically. The ownership of files outside of the user's home directory must be fixed manually. -U, --unlock Unlock a user's password. This removes the '!' in front of the encrypted password. You can't use this option with -p or -L. Note: if you wish to unlock the account (not only access with a password), you should also set the EXPIRE_DATE (for example to 99999, or to the EXPIRE value from /etc/default/useradd). -Z, --selinux-user SEUSER The SELinux user for the user's login. The default is to leave this field the blank, which causes the system to select the default SELinux user. Caveats
A40
Author: this command fixed my mistake I made above ;) source: http://www.cyberciti.biz/faq/howto-change-default-home-directory/
A42
Author: source: http://www.cyberciti.biz/faq/linux-remove-delete-symbolic-softlink-command/
Page 3: List of important debian Commands.xlsx

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

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

Search a file or any output and more:

Mysql console Commands:

# show databases;

# drop database <db_name>

* Copy files:

rsync -av ./* metropolis/ --exclude=metropolis << (a) options replaces [archive mode; equals -rlptgoD]

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

grep word filename or grep word file1 file2 file3

# mysql -u username -p

# use db_name;

# grant all on db_name.* to 'username'@'localhost';

# set password for 'username'@'localhost'=password('new-passwd');

↑↑ beaware that (*) arsetic deosn't equal "recurrsive'' it only goes one level deep in "rsync".. So always use the recurrsive option and refer to man page to know wether it's upper or lower case since it differs between commands

# sudo rm -rvI *

Page 4: List of important debian Commands.xlsx

* Backup commands and restore and all:

1) sudo tar -cvpzf 3qnx_server_full_nginx_php5fpm_barebone.tar.gz --one-file-system --exclude=/home/heisenberg/Backup_Files/3qnx_serv

2) sudo scp -c arcfour -v -p /home/heisenberg/Backup_Files/3qnx_server_full_nginx_php5fpm_barebone.tar.gz [email protected]:/

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

mysql -p -u username(of the db) database_name < /path/file.sql

* Export mysql database: (execute this command ouside mysql console)

mysqldump -u username -p database_name > database_name.sql

* New safe and flexible way for deleting files or folders and more:

For multible folders use the below syntax:

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

* Import sql dumb file into new db out the mysql console:

find . -path ./<folder_name> -prune -o ! -path . -ls

or with same result and easier >> find . mindepth 1 -path ./<folder_name> -prune -o -action

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

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

or with same result and easier >> find . mindepth 1 -type d \( -path ./<folder_name1> -o -path ./<folder_name2> \) -prune -o -action

Page 5: List of important debian Commands.xlsx

* For testing commands the following will help create dummy files +folders:

The steps are: 1- $ mkdir a b c d e

* Creating soft sym- links:

ln -s <target_folder or files> <the_shortcut(link)_path>

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

2) screen -r << to resume the session ##### screen -d << to deattach from a session but u can log back of course

3) screen -D -r screensession_name << helps if screen -r doesn't work, this will deattach then reattach back

Extra commands:

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_name

To check which version of package is installed on system compared to ur repository(sources.list):

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

2- $ touch a/1 b/2 c/3 d/4 e/5 e/a e/b

* Creating a resumable ssh session by "Screen" steps: (to aviod killing proccess like scripts)

CTRL+a ,then c >>> to create a new window

CTRL+a , n to switch to the next window in your screen session

CTRL+a , p to switch to the previous window in your screen session

A110
Author: source: 1) http://aperiodic.net/screen/quick_reference 2) http://unix.stackexchange.com/questions/479/keep-ssh-sessions-running-after-disconnection
Page 6: List of important debian Commands.xlsx

apt-cache policy package_name

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

To test I/O disk speed

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

dd if=/dev/zero of=iotest bs=64k count=16k conv=fdatasync && rm -fr iotest

time sh -c "dd if=/dev/zero of=ddfile bs=8k \ plus count=250000 && sync"; rm ddfile

* Activate dropbox:

/usr/bin/python dropbox.py

Monitor packets that reach the server:

vnstat -l -i venet0

How to flood server:

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

hping3 -q -n -a 10.0.0.1 --id 0 --icmp -d 56 --flood target_ip_address

A152
Author: source: http://jeremymarc.github.io/2013/04/22/nginx-and-php-fpm-for-performance/
Page 7: List of important debian Commands.xlsx

ps -ylC php5-fpm --sort:rss | awk '!/RSS/ { s+=$8 } END { printf "%s\n", "Total memory used by PHP-FPM child processes: "; printf "%dM\n", s/1024 }'

To Find Cache Memory uses in Linux

free -m

mysqldump -u 3qdatabase -p 3qdotcomwp260 > database_3qlani_03_sep_2014.sql

Page 8: List of important debian Commands.xlsx

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 the TTY, though

If you have multiple suspended commands, running, it will be listed

In the above example this command would list each of the files in the current directory and the files permissions, the size of the file, date of the last modificationto 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 affected

display line numbering in vim

logs out or get back to your user level (after su) (or a different user)

kill a suspended program, you don't have to bring it back with fg first

List the contents of the parent directory.

Page 9: List of important debian Commands.xlsx

* Another feature is to launch a search on the word where the cursor is positioned. Place the cursor over the word to search for, then press * or # to to look it up.

argumnets are: stop, start, status

tests nginx config. Files sytax and health

3) result was ok with all options and groups appended and password but the new user home folder was moved into the root since I was logged 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

Page 10: List of important debian Commands.xlsx

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 dealing with folder..

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

delete contents of current folder -r >> recurrsive v >> verbose I>> only one warning

beaware that (*) arsetic deosn't equal "recurrsive'' it only goes one level deep in "rsync".. So always use the recurrsive option and refer to man page to know wether it's upper or lower case since it differs between commands

Page 11: List of important debian Commands.xlsx

delete contents of the folder only but not the folder that why we put asterisk…. -r >> recurrsive v >> verbose f>>ignore nonexistent files, never prompt

Backup command

secure copy to server

Restore command

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

mindepth 1 = ! -path . >> (is to exclude the current directory itself but not the content always use it to protect current direc.)

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

mindepth 1 = ! -path . >> (is to exclude the current directory itself but not the content always use it to protect current direc.)

execute action on all current directory (.) content but excluding one folder and it's whole content. The exclusion is done by (- path ./<folder_name> -prune -o) since prune does not descend into folder specified but DO NOT use with -delete action since it includes -depth option and cancels =prune.. ! -path . (is to exclude the current directory itself but not the content always use it to protect current direc.)

Page 12: List of important debian Commands.xlsx

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

terminates session

Page 13: List of important debian Commands.xlsx
Page 14: List of important debian Commands.xlsx

ps -ylC php5-fpm --sort:rss | awk '!/RSS/ { s+=$8 } END { printf "%s\n", "Total memory used by PHP-FPM child processes: "; printf "%dM\n", s/1024 }'

Page 15: List of important debian Commands.xlsx

In the above example this command would list each of the files in the current directory and the files permissions, the size of the file, date of the last modification

Page 16: List of important debian Commands.xlsx

execute action on all current directory (.) content but excluding one folder and it's whole content. The exclusion is done by (- path ./<folder_name> -prune -o) since prune does not descend into folder specified but DO NOT use with -delete action since it includes -depth option and cancels =prune.. ! -path . (is to exclude the current directory itself but not the content always use it to protect current direc.)

Page 17: List of important debian Commands.xlsx

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

Page 18: List of important debian Commands.xlsx

* Adding aliases to .bashrc to shortcut commands steps:1) alias shortcut_name='command to be aliased'

2) source .bashrc

* Exim4 cheatsheet:

exim -v [email protected]

exim -bp | exiqgrep -i | xargs exim -Mrm

exim -Mrm {message-id}

Page 19: List of important debian Commands.xlsx

add this to .bashrc file

send test mail with debugging

flush mail queue

delete one message

Page 20: List of important debian Commands.xlsx

Bash script to create MySQL database and user:

#!/bin/bash

echo -n "Enter the MySQL root password: "read -s rootpwecho -n "Enter database name: "read dbnameecho -n "Enter database username: "read dbuserecho -n "Enter database user password: "read dbpw

db="create database $dbname;GRANT ALL PRIVILEGES ON $dbname.* TO $dbuser@localhost IDENTIFIED BY '$dbpw';FLUSH PRIVILEGES;"mysql -u root -p$rootpw -e "$db"

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

A3
Author: soyrce: http://www.linuxdigest.org/2012/06/bash-script-to-create-mysql-database-and-user/
Page 21: List of important debian Commands.xlsx

Mysql console Commands:

# show databases;

# 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 "character_set_database"; and show variables like "collation_database";

Discover default character set and collation for the MySQL server:

SHOW VARIABLES LIKE 'character_set%' and SHOW VARIABLES LIKE 'collation%';

# mysql -u username -p

# use db_name;

# grant all on db_name.* to 'username'@'localhost';

# set password for 'username'@'localhost'=password('new-passwd');

Page 22: List of important debian Commands.xlsx

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];

1- USE your_database_of_interest; >> 2- show variables like "character_set_database"; and show variables like "collation_database";

SHOW VARIABLES LIKE 'character_set%' and SHOW VARIABLES LIKE 'collation%';