Skip to main content

Posts

Showing posts with the label Linux

How to use Linux fold command in bash script

The fold command can be very useful in many scenarios. It allows you to break up text and then use it in a loop. In this post, we will review the fold command and see how it can be used in a bash script and as command argument to format text. The basic use of the fold command is to take long lines of text and break them into shorter pieces. One common use is to shorten lines in a text file so that they display well in a terminal window. Lines wider than the terminal width might otherwise wrap in inconvenient places. The fold command can also be used to create a narrower formatted file from a file with lines that are inconveniently long. $ fold wide.txt > narrow.txt If a text file contained a single line with 346 characters including the final newline like that shown below, it would wrap, but not necessarily in a way that would look right. $ cat khs Kendra Harry-Stocker has been administering Unix systems for more than 30 years. She describes herself as “USL” (Unix as a second la...

Linux File and Directory Permissions

file & directory protection is a essential of any OS and Linux OS is no exception for it! These authorizations allow you to choose exactly who can access your files & directory, providing an overall improved system security. There was one of the major flaws in the older Windows operating-system where, by standard, all users can see each other people's information (Windows 95, 98, Me). For overcoming it, editions of the Windows based computer system such as NT, 2000, XP and 2003 lot more security features added. They fully support file & directory permissions, just as Linux system has since the beginning. Together, we'll now assess a directory listing from our Lab Linux system hosting server, to help us understand the information provided. a simple 'ls' command will give you the file and directory listing within a given directory, including the option  '-l' will display number of new areas that we are going to discuss here:

How to upgrade PHP 5.1 to PHP 5.3 using yum on CentOS

This information explains how to update the standard PHP 5.1.x packages in CentOS 5.x 32-bit to the current development versions 5.3.x. These guidelines were designed using CentOS 5.5 32-bit and with the following PHP packages installed: # rpm -qa |grep php php-common-5.1.6-15.el5.i386 php-cli-5.1.6-15.el5.i386 php-5.1.6-15.el5.i386 php-pdo-5.1.6-15.el5.i386 php-bcmath-5.1.6-15.el5.i386 php-ldap-5.1.6-15.el5.i386 php-devel-5.1.6-15.el5.i386 php-gd-5.1.6-15.el5.i386 php-xml-5.1.6-15.el5.i386 php-mbstring-5.1.6-15.el5.i386 php-mysql-5.1.6-15.el5.i386 php-dba-5.1.6-15.el5.i386 Provided that you're using the standard PHP packages on your CentOS server you won't need to do anything additional. If you're using additional PHP packages that aren't part of the standard CentOS repositories (like php-mcrypt) you'll have to remove them or find out updated versions of them. Add the Atomic repositories First thing we need to do is add the atomic repos...

How to Upgrade to Perl 5.12.5 on Linux Machine

Upgrading Perl from source on Linux This tutorial explains how to compile Perl 5.12 for a Linux machine. In this tutorial, CentOS 5 / Red Hat Enterprise Linux 5 will be used, however the procedure should be quite similar for other distributions of Linux as well. Note:  You may be tempted to do a `yum remove perl` to remove the 5.8 version that your distribution came with. Don't. I'll give an explanation why later on. Does your vendor already have Perl 5.12? If you can install Perl 5.12 via yum, apt, portage, or whatever your package manager is, I highly recommend you do it. It's always better to install things so that your package manager is aware of their existence rather than to go ahead and install something behind its back. If all you can get is Perl 5.8, though, you'll need to compile it yourself. Download the Perl Source Just link to  http://search.cpan.org/dist/perl/  and click the "Download" link at the top of the page. That should get you th...

Set Windows as Default OS when Dual Booting Ubuntu

Set Windows as Default OS in OS choice menu when Dual Booting Ubuntu & Windows When you install a dual-boot of Ubuntu, one of the frustrating things that you’ll immediately notice is that Ubuntu is now set as the default operating system in the Grub loader. There’s an easy way to switch back to using Windows as the default. To make this change, you’ll first have to boot into Ubuntu, and then run the following command: sudo gedit /boot/grub/menu.lst Find this section of the file: ## default num # Set the default entry to the entry number NUM. Numbering starts from 0, and # the entry number 0 is the default if the command is not used. # # You can specify ’saved’ instead of a number. In this case, the default entry # is the entry saved with the command ’savedefault’. # WARNING: If you are using dmraid do not change this entry to ’saved’ or your # array will desync and will not let you boot your system. default 0 The important line is the last...

Installing Ubuntu 10.04 LTS

Ubuntu 10.04, also known as the Lucid Lynx, arrived on April 29th, 2010 and is the twelfth release of the Ubuntu OS. We've created the following tutorial to teach Linux newcomers how to install the Ubuntu 10.04 LTS operating system on their personal  computer. Therefore, it is addressed to people who have just heard about Ubuntu, those who have never installed Ubuntu before and want to test it, but don't know how. The tutorial will make things very simple for you, but if you get stuck somewhere in the middle of the installation and you need help, do not hesitate to use our commenting system at the end of the article! Requirements: You will need the Ubuntu 10.04 LTS Desktop ISO image that corresponds to your hardware architecture (i386 or amd64), and that can be downloaded from here . When the download is over, burn the ISO image with your favorite CD/DVD burning application (Nero, CDBurnerXP, Roxio) on a blank CD at 8x speed. Reinsert or leave the CD in your CD/DVD-R...

Installing Ubuntu with Windows Dual-Boot

Introduction This page describes how to set up your computer in order to dual boot Ubuntu and Windows. Back Up Your Data Although this may seem obvious, it is important to backup your data files to an external backup medium before attempting a dual-boot install (or any other hard drive manipulation), in case your hard drive becomes corrupted during the process. External hard drives, USB flash drives, and multiple DVDs or CDs are useful as external backup media. Have a Windows recovery CD/DVD available Many computer manufacturers that pre-install Windows provide a Windows recovery/re-installation CD or DVD with the computer. However, many companies no longer ship a physical disk but instead create a hidden partition on the hard drive in which the recovery-disk information is stored. A utility is then usually provided which allows the user to burn a recovery/re-installation CD or DVD from it. If you are buying a new computer and intent on dual-booting, make su...

Handy Command Line Tricks for Linux

If you have limited Unix / Linux experience but are starting to use the shell to manage your applications, installation, here are some handy command line tricks that will help you do common things a lot faster. Also, the commands listed here aren’t specific to any shell so you should be able to use them in any Linux environment. 1. Linux comes in several flavors. The following commands will help you determine whichLinux distribution is installed on your host, what’s the version of your Linux kernel, the CPU model, processor speed, etc. $ cat /etc/issue $ cat /proc/version $ cat /proc/cpuinfo 2. Find the total amount of RAM available on your Linux box and how much is free. $ free -mto 3. The command cd.. takes you up one directory level but cd – will move you to the previous working directory. Or use the command pwd to print the full path of the current directory that you can copy-paste later into the shell. $ cd – $ pwd

installing php apc gnulinux centos-5

Complex PHP applications, such as Drupal, can gain a lot of performance benefits from running a PHP op-code cache/accelerators. APC, Alternate PHP Cache, is now the most maintained free/open source op-code cache, and is being used more and more as it emerges to be the most stable. The instructions here detail how to get APC running on a CentOS 5 server. The server happened to have Plesk on it as well, which initially made me hesitant to install APC "normally", since Plesk is so picky on what other software is installed on the server. However, it seems to have worked out well. First, we need the pecl command so we can download and install APC from the repositories. Do to so, we execute the following command: yum install php-pear But, this will not run on its own, we need the following package for the phpize command: yum install php-devel We also need the apxs command, which is installed via the following package: yum install httpd-de...

How to mount ISO in solaris & resolve error (iso is not a multiple of 512)

Many software packages download are in the form of an ISO image. Rather than burning the image to a CD-ROM to access its contents, it is easy to mount the image directly into the Solaris file-system using the lofiadm and mount commands. Given an ISO image in /export/temp/Compusoft.iso, a loopback file device (/dev/lofi/1) is created with the following command: #lofiadm -a /export/temp/Compusoft.iso Output      /dev/lofi/1 The lofi device creates a block device version of a file. This block device can be mounted to /mnt with the following command: #mount -F hsfs -o ro /dev/lofi/1 /mnt These commands can be combined into a single command: #mount -F hsfs -o ro `lofiadm -a /export/temp/Compusoft.iso` /mnt Sometimes when you convert image from .nrg to .iso & converted image is not a multiple of 512 bytes. lofiadm refuses. Unmount and detach the images Use umount command to unmount image: #umount /mnt Now remove/free block device: #lofiadm...