Some Important Linux command for Newbies
My first experience with Linux started when i setup a server for one my client. It was monumental task for me at that time. I was a happy mouse driven windows user. When I came to the world of putty I was lost. So I had to search for certain commands. I recently Setup LAMP With Ubuntu In 10 Minutes. One of my colleague tried to setup LAMP following that post. He was also a happy mouse driven windows user So he was having problem with commands. In this post I am showing all the commands I needed and used to use Linux server. I will post all the problems i faced using LAMP in next post.
To create new directory
mkdir target_director
To copy an entire folder (directory tree) in Linux
cp -ap /var/lib/mysql /mnt/mysql -ap for same permission as source
For checking the size of current folder
du -ch | grep total
To find the size of the hdd
just enter df
To find out the size of the folder in the folder
du du -a to show all the file's size
See all files and their size
du -s * -h
To output the number of files in the current directory
ls | wc -l
See all the jobs
ps -aux
To find out RAM size on Linux machine
free
Rename folder/filename
mv test hope mv *.rtf *.txt
To find which process is consuming how much RAM?
top
To see the free ram memory
free -m
To update yum using corn
0 21 *** usr/bin/yum -y update
Create tar.gz file
tar czvf myfolder.tar.gz abcfolder/
Untar a tar file
tar czvf myfolder.tar.gz abcfolder/
[/sourcecode]
Delete bash History
Try to delete the content of ~/.bash_history
To add new user
* Adding a new user (useradd)
* Modifying an existing user (usermod)
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
useradd -gusers -Gmgmt -s/bin/shell -pass -d/home/jambura -m jambura
User’s home directory should be 700. If you are operating a ~username type server, the public_html directory should be 777. You may also need to open up the home directory to 755.
useradd -s/bin/bash -pass -d/imp/sysbsd -m sysbsd
For allowing sudo
sudo adduser jambura admin
To delete user
userdel user
To display your crontab file
crontab -l
root can view any users crontab file by adding “-u username”
crontab -u bappy -l # List bappy's crontab file.
* * * * * Command to be executed
- – - – -
| | | | |
| | | | +—– Day of week (0-6)
| | | +——- Month (1 – 12)
| | +——— Day of month (1 – 31)
| +———– Hour (0 – 23)
+————- Min (0 – 59)
Field Allowed values
—– ————–
minute 0-59
hour 0-23
day of month 1-31
month 1-12 (or names, see below)
day of week 0-7 (0 or 7 is Sun, or use names)
To edit crontab file
crontab -e
#change the editor used to edit file set the EDITOR environmental variable like this:
export EDITOR=/usr/bin/emacs
Get sub categories and product count in magento
Happy Tuesday Folks !
By the following code you will be getting subcategories and all products (product count) form the parent category.
First you have got to insert the Parent ID and then the code below will display you subcategories in it and all products (product count) from the sub categories.
<?php
/* How will get sub categories and products from parent category in magento?*/
$parentId = 2; // Put parent category Id here
$cat = Mage::getModel('catalog/category')->load($parentId);
$subcatcollection = $cat->getChildren(); // Sub categories id with string
$subcatcollection = explode(",",$subcatcollection);// Will return all sub categories
foreach($subcatcollection as $singlecat): // Find sigle subcategory form loop
$fcat = Mage::getModel('catalog/category')->load($singlecat); //Single category information
if($fcat->getIsActive()): // Check Category is Active
$_proCollection = Mage::getResourceModel('catalog/product_collection')
->addCategoryFilter($fcat)
->setOrder('name', 'ASC'); //Sort by Product Name
$_collectionSize = count($_proCollection); //Will return number of products category.
?>
<a href="<?php echo $this->getUrl().$fcat->getUrl_path(); ?>" title="<?php echo $fcat->getName(); ?>">
<?php echo $fcat->getName(); ?>
</a><!-- Show Categoy Name & Url. -->
<?php
foreach ($_proCollection AS $ffproduct):
$cur_fproduct = Mage::getModel('catalog/product')->load($ffproduct->getId());
//product all information.
if($cur_fproduct->getVisibility()!=1):
?>
<a href="<?php echo $this->getUrl().$cur_fproduct->getUrl_path(); ?>">
<?php echo $cur_fproduct->getName(); ?>
</a> <!-- Show Product Name & Url. -->
<?php
endif;
endforeach;
?>
<?php endif; ?>
<?php endforeach; ?>
Thanks and feel free to share your comments.
Install Magento on godaddy server
First of all, open root .htaccess file then replace
#Options-MultiViews
with
Options-MultiViews
if it is not working then please add the line below in php.ini file:
cgi.fix_pathinfo = 1
Still having issues ? rename php.ini file to php5.ini file form the root and
you should be good now.
Thanks and feel free to share your comments.

