Tag: linux


Installing xdebug in XAMPP 1.8.3 on Linux

If you have installed XAMPP 1.8.3-0 for Linux and you want to install x-debug here is how to do it using PECL. 1.) Check to make sure /bin is in your path echo $PATH; if :/bin: is in the path then bin is in your path. This makes sure that when you c...

Don't overwrite permissions with tar file

When you use tar to back-up a directory and then you want to restore that directory you may want to keep existing permissions intact. If you made changes to the permissions since the archive was created and you want to restore the original files while ...

Compare the contents of a remote directory with a local directory

Here is a little PHP script I wrote, that you can run from the command line. I wrote it to allow you to see what files are in a remote folder that are not in a local folder. user@localhost the_directory> php compare.php the_host_address.com:/the/remot...

Jump to end of file with vi or vim | Jump to last line

Insert Mode is when you have a block cursor and can edit the text Command Mode is when you have a : at the bottom where you can enter commands. If you are in insert mode or command mode hit: escape key then shift+g keys If you are not in insert mode...

Add an existing user to an existing group in Linux

If you want to a add a user to an existing group this is how you do it. [local_username@localhost /]$ useradd -a -G somegroup usernameThen log out and log back in for the new group settings to take effect.Managing permissions for a group is an importan...

Exclude images from a Linux find

If you want to find all files in a sub directory and you don't want images to show up in the list here is a way to do it: [local_username@localhost /]$ find /some/dir/ -type f \( -name '*.png' -o -name '*.jpg' -o -name '*.jpeg' -o -name '*.gif' \) -pr...

List all users on a server

User information is stored in the /etc/passwd file [username@localhost /]$ awk -F":" '{ print $1 }' /etc/passwd If you want to print out the user name and UID: [username@localhost /]$ awk -F":" '{ print $1 "\t\t"$3 }' /etc/passwd | column -t Here is ...

Copy MySQL schema from remote host to local host

The secret is to use a program called mysqldump which comes with your installation of mysqld. user@localhost the_directory>mysqldump --no-data -u root remote_db_name -h address_of_remote_machine.com > temp-db-schema.mysql user@localhost the_directory...

Copy all files a user owns off of remote server

This is for copying files from a Linux machine to a local Linux machine. user@localhost the_directory> ssh user_name@remote_domain.com 'cd /dir/you/want/to/copy/; find `pwd` -user user_name' | xargs -I{} scp user_name@remote_domain.com:{} `pwd` This...

Change ownership of files owned by only one user

To find all the files owned by a specific user and then change their group and user ownership to something else use the example in green and follow the directions on what to replace in the green example: Replace enter_user_name_here with the specific ...

Sort ls -l output

To sort the command "ls -l" output by each column in Linux use the following commands: user@server the_directory> ls -l | sort -k3 Let's break this down: ls - lists the files in the current directory -l - tells the "ls" command to list all the info...

Install PHP CLI with MySqli extension/module on Linux

So you want to use PHP from the command line or you have PHP from the command line but you don't have mysqli installed. run the following shell script: #!/bin/bash echo "Are you logged in as root?"; select yn in "Yes" "No"; do case $yn in ...

Installing PECL command on a Linux box

PECL is a command that comes with PEAR. PECL allows you to load PHP extensions which are programmed in C. to install it use the package manager that comes with your brand of Linux: apt-get install php5-pear or yum install php-pear or... rpm php-pear

Convert string to list of ASCII codes in bash

If you want to take a string and get the ascii code for each character in the string using a bash script then use the following function: function string2ascii_codes { str=$1; list=($(echo $str|sed 's/\(.\)/\1 /g')); ascii_result=''; ...

Only list files | don't list directories | "find" command in Linux

How to: Find all files under a directory Find only files from the command line in Linux Don't search for directories [user@machinename ~]$ find /some/directory -type f -name filename Replace "/some/directory" with your directory "-type f" means on...

Check if a database exists in MySQL from the command line

To check if a database exists from the command line in MySQL echo the following query and pipe (|) it to the MySQL command line utility:echo SELECT COUNT(*) as num FROM INFORMATION_SCHEMA.SCHEMATA WHERE SCHEMATA.SCHEMA_NAME="some_database_name"; | mysq...

Find a file by name in Linux and don't show permission denied

Looks for a file named "game" starting at the root directory (searching all directories including mounted filesystems). The `-name' option makes the search case sensitive. You can use the `-iname' option to find something regardless of case. find / -...

Example: change a user's password in Linux

A simple example of changing a user's password #Change a user's password user@localhost the_directory> passwd username #Change your own user@localhost the_directory> passwd It is too bad that Google favors long content. I just wanted a simple exampl...