//Clear ACL counters:
router#clear access-list counters
//
Router#show run | include frame-relay map
-------------------------------------APPs Version--------------------------------------------------
//mysql:
mysql> select version();
$mysql -V
//Linux kernel
$uname -a
//CentOS
cat /etc/redhat-release
//Postfix
postconf | grep mail_version
//Dovecot
dovecot --version
-------------------------------------POSTFIX 2.7.2------------------------------------------
//Show queue
#postqueue -p
//empty queue
#postsuper -d all
//Check for MySQL support in Postfix
#postconf -m
//Check for SASL support
#postconf -a
//Postfix configuration file: main.cf
-------------------------------------MySQL--------------------------------------------------
//New user
CREATE USER 'developer'@'localhost' IDENTIFIED BY 'letmein';
//Grant permissions.
GRANT ALL ON DEVELOPMENT_database.* to 'developer'@'localhost';
//Table definition
SHOW CREATE TABLE table_name;
-------------------------------------LINUX--------------------------------------------------
//Searching a string in a folder:
grep -r "string_to_find" /home/mydocuments
//OR use PCRE:
pcregrep -r "string_to_find" /home/mydocuments
//To search for a file in a folder use find:
find /home/mydocuments -name index.php
//Remove directory and its contents
$rm -rf directoryname
//Symbolic link
$ ln -s /webserver/programs/bin/httpd httpd
//Set a file's owner:
$ chown username somefile
//Set a directory's owner:
$ chown username somedirectory
//In order to set the ownership of a directory and all the files in that directory, you'll need the -R option (recursive):
$ chown -R username somedir
//You can also set the file's group at the same time.
//If the user name is followed by a colon and a group name, the file's group will be changed as well.
$ chown username:groupname somefile
//adding a user in CentOS
useradd "username" -g"group"
//adding a group in CentOS
groupadd "groupname"
//change a user password
passwd "username"
//viewing users in CentOS
cat /etc/passwd
//viewing groups in CentOS
cat /etc/groups
//deleting a user in CentOS
userdel "username"
//deleting a group in CentOS
groupdel "groupname"
//change a file's group
chgrp "newgroupname" "file"
//Conditional permissions recursively (only files),a combination of FIND and CHMOD.
//Finding files with 777 permisions and changing them 755:
find /webserver/webroot -type f -perm 777 -exec chmod 755 {} \;
//Finding direct children (files) of a directory with 777 permissions
find /webserver-maxdepth 1 -perm 777
//Finding files with specific permissions
find /webserver/webroot -perm 777
//Setting permissions with CHMOD by number (Also see: Filesystem ACLs)
chmod 755 index.php
0 = --- = no access
1 = --x = execute
2 = -w- = write
3 = -wx = write and execute
4 = r-- = read
5 = r-x = read and execute
6 = rw- = read and write
7 = rwx = read write execute (full access)
...So,
Triplet for u: rwx => 4 + 2 + 1 = 7
Triplet for g: r-x => 4 + 0 + 1 = 5
Tripler for o: r-x => 4 + 0 + 1 = 5
//Compress a directory:
$ tar -zcvf webroot-1-jan-20013.tar.gz /webserver/webroot
//Decompress a directory (extract):
$ tar -zxvf webroot-1-jan-20013.tar.gz /webserver/webroot -C /newserver
//To copy a file from hostB to hostA, while logged in to hostB:
[user@server ~]$ scp -P port filename username[at]hostA.com:.
//(copies file to user's home dir on hostA machine, because of the period after the colon)
//To copy a folder from hostB to hostA, while logged in to hostB first cd to
//the directory on HostB which contains the folder you want to copy:
[user@server ~]$ scp -r -P port folder username[at]hostA.com:.
//(creates new folder if the folder does not exist, again in user's home directory)
//To copy a file from hostA to hostB, while logged in to hostB:
[user@server ~]$ scp -P port username[at]hostA.com:filename .
//(copies into current directory on hostB)
[user@server ~]$ scp -r -P port username[at]hostA.com:folder .
//(copies whole folder into current directory on hostB)
//To copy a file or folder within a folder from hostA to hostB, while logged in to hostB:
[user@server ~]$ scp -P port username[at]hostA.com:/folder/dir/filename .
//(copies into current directory on hostB)
[user@server ~]$ scp -r -P port username[at]hostA.com:/folder/dir .
//(copies whole folder into current directory on hostB)
//Instead of using the '.' to designate files to be copied to a home directory or
// the current working directory you can give scp an actual path (assuming you have write permissions):
[user@server ~]$ scp -r -P port folder username@hostA:/home/httpd/
[user@server ~]$ scp -P port username[at]hostA.com:/folder/dir/filename /home/tmp/
//Searches all files for $_SERVER['SERVER_NAME'] and replaces it with SiteMode()
//Combination of find and sed
find /webserver/html/ -type f -exec sed -i "s/\$_SERVER\['SERVER_NAME'\]/SiteMode()/g" {} \;
//Displaying routing table in CentOS
route -n
netstat -rn
ip route list
//linux command to find the size of a directory
du -sh directory/
//hard disk used/available space
df -h
[ view entry ] ( 1892 views ) | print article
<<First <Back | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 |