Mount NTFS file system in Linux



Most of the linux distributions come without NTFS support. For adding NTFS support to linux we use NTFS-3G driver. The NTFS-3G driver is a free and commercially available and supported read/write NTFS driver for unix-type (Linux) operating systems. It provides safe and fast handling of the Windows XP, Windows Server 2003, Windows 2000, Windows Vista, Windows Server 2008 and Windows 7 file systems.



The latest stable version of NTFS-3G can be found at http://www.ntfs-3g.org/


NTFS-3G uses FUSE lib ( Filesystem in Userspace ). FUSE provides set of functions to implement file system in a userspace program.
The latest version of FUSE can be found at http://fuse.sourceforge.net/
Installation:
Download NTFS-3G and FUSE from above links
Untar FUSE
Install fuse with following command


#./configure
# make
# make install
# modprobe fuse


Untar NTFS-3G package then type


#./configure
# make
# make install
If there is no error in the installation, ntfs drive can be mounted in read/write mode
mount the drive with -t ntfs-3g option as follows:
# mount /dev/sda1 -t ntfs-3g /mnt/win

Change file attribute in Linux

The following command to write protect /root/test.txt file:


[root@localhost]# chattr +i test.txt


A file with the 'i' attribute cannot be modified: it cannot be deleted or renamed, no link can be created to this file and no data can be written to the file.
The list of Linux second extended file system using the lsatter command (run as root user  )


# lsattr /root/test.txt----i-------- /root/test.txt

For rest of Linux second extended file system attributes read man chatter, man lsatter.

Before doing this root need to remove the attribute using command:

# chattr -i /root/test.txt
# lsattr /root/test.txt------------- /root/test.txt



















Change Display Resolution

Short Cut Key of changing resolution

Desk Top [Ctrl]+[Alt]+[+] or [-]
Lap Top [Ctrl]+[Alt]+[Fn]+[+] or [-]
If doesn't work above keys, you need to edit /etc/X11/XF86Config
Change Resolution Options
Edit /etc/X11/XF86Config
...
Section "Screen"
Driver "accel"
Device "S3 Inc.
Trio 64V2/DX or /GX"
Monitor "Acer 34TL"
DefaultColorDepth 8
Subsection "Display"
Depth 8
Modes "1024x768"
ViewPort 0 0
EndSubsection
EndSection
...
Change Color


Depth 8
Change Resolution


Modes "1280x1024" "1152x864" "1024x768" "800x600" "640x480"


Package Managers in Debian


Debian based systems (including Ubuntu) uses apt-* commands for managing packages from the command line.
In this article, using Apache 2 installation as an example, let us review how to use apt-* commands to view, install, remove, or upgrade packages.
1. apt-cache search: Search Repository Using Package Name If you are installing Apache 2, you may guess that the package name is apache.2.  To verify whether it is a valid package name, you may want to search the repository for that particular package name as shown below.
The following example shows how to search the repository for a specific package name.
$ apt-cache search ^apache2$
apache2 - Apache HTTP Server metapackage

2. apt-cache search: Search Repository Using Package Description

If you don’t know the exact name of the package, you can still search using the package description as shown below.
$ apt-cache search "Apache HTTP Server"
apache2 - Apache HTTP Server metapackage
apache2-doc - Apache HTTP Server documentation
apache2-mpm-event - Apache HTTP Server - event driven model
apache2-mpm-prefork - Apache HTTP Server - traditional non-threaded model
apache2-mpm-worker - Apache HTTP Server - high speed threaded model
apache2.2-common - Apache HTTP Server common files

3. apt-file search: Search Repository Using a Filename from the Package

Sometimes you may know the configuration file name (or) the executable name from the package that you would like to install.
The following example shows that apache2.conf file is part of the apache2.2-common package. Search the repository with a configuration file name using apt-file command as shown below.
$ apt-file search apache2.conf
apache2.2-common: /etc/apache2/apache2.conf
apache2.2-common: /usr/share/doc/apache2.2-common/examples/apache2/apache2.conf.gz

4. apt-cache show: Basic Information About a Package

Following example displays basic information about apache2 package.
$ apt-cache show apache2
Package: apache2
Priority: optional
Maintainer: Ubuntu Core Developers
Original-Maintainer: Debian Apache Maintainers
Version: 2.2.11-2ubuntu2.3
(>= 2.2.11-2ubuntu2.3)
 | apache2-mpm-prefork (&g
Depends: apache2-mpm-worke
rt;= 2.2.11-2ubuntu2.3)
 | apache2-mpm-event (>= 2.2.11-2ubuntu2.3)
6350
Description: Apache HTTP Server metapackage
The Apache So
Filename: pool/main/a/apache2/apache2_2.2.11-2ubuntu2.3_all.deb
Size:
4ftware Foundation's goal is to build a secure, efficient and
extensible HTTP server as standards-compliant open source software.
Homepage: http://httpd.apache.org/

5. apt-cache showpkg: Detailed Information About a Package

“apt-cache show” displays basic information about a package. Use “apt-cache showpkg” to display detailed information about a package as shown below.
$ apt-cache showpkg apache2
Package: apache2
Versions:
untu2.3 (/var/lib/apt/lists/us.archive.ubuntu.com_ubuntu_dists_jaunty-updates_main_binary-i386_Packages) (/var/lib/apt/lists/security.ubuntu.com_ubuntu_dists_jaunty-security_main_binary-i386_Packages)
Descript
2.2.11-2u
bion Language:
File: /var/lib/apt/lists/us.archive.ubuntu.com_ubuntu_dists_jaunty-updates_main_binary-i386_Packages
MD5: d24f049cd70ccfc178dd8974e4b1ed01
Reverse Depends:
squirrelmail,apache2
squid3-cgi,apache2
mahara-apache2,apa
phpmyadmin,apache2
che2
ipplan,apache2
Dependencies:
2.2.11-2ubuntu2.3 - apache2-mpm-worker (18 2.2.11-2ubuntu2.3) apache2-mpm-prefork (18 2.2.11-2ubuntu2.3) apache2-mpm-event (2 2.2.11-2ubuntu2.3)
2.2.11-2ubuntu2 - apache2-mpm-worker (18 2.2.11-2ubuntu2) apache2-mpm-prefork (18 2.2.11-2ubuntu2) apache2-mpm-event (2 2.2.11-2ubuntu2)
Provides:
2.2.11-2ubuntu2.3 -
2.2.11-2ubuntu2 -
Reverse Provides:
apache2-mpm-itk 2.2.6-02-1build4.3
apache2-mpm-worker 2.2.11-2ubuntu2.3
apache2-mpm-prefork 2.2.11-2ubuntu2.3
apache2-mpm-prefork 2.2.11-2ubuntu2
apache2-mpm-event 2.2.11-2ubuntu2


6. apt-file list: List all the Files Located Inside a Package

Use “apt-file list” to display all the files located inside the apache2 package as shown below.
$ apt-file list apache2 | more
apache2: /usr/share/bug/apache2/control
apache2: /usr/share/bug/apache2/script
bian.gz
apache2: /usr/share/doc/apache2/README
apache2: /usr/share/doc/apache2/NEWS.D
e.Debian.gz
apache2: /usr/share/doc/apache2/changelog.Debian.gz
...

7. apt-cache depends: List all Dependent Packages

Before installation, if you like to view all the dependent packages, use “apt-cache depends” as shown below.
$ apt-cache depends apache2
apache2
|Depends: apache2-mpm-worker
|Depends: apache2-mpm-prefork
Depends: apache2-mpm-event

8. dpkg -l: Is the Package Already Installed?

Before installing a package, you may want to make sure it is not already installed as shown below using dpkg -l command.
$ dpkg -l | grep -i apache

9. apt-get install: Install a Package

Finally, install the package using “apt-get install” as shown below.
$ sudo apt-get install apache2
[sudo] password for ramesh:
he following NEW packages will be installed:
T apache2 apache2-mpm-worker apache2-utils apache2.2-common libapr1
libaprutil1 libpq5
stalled, 0 to remove and 26 not upgraded.
0 upgraded, 7 newly i
n

10. dpkg -l : Verify Whether the Package got Successfully Installed

After installing the package, use “dpkg -l” to make sure it got installed successfully.
$ dpkg -l | grep apache
ii apache2 2.2.11-2ubuntu2.3 Apache HTTP Server metapackage
ii apache2-mpm-worker 2.2.11-2ubuntu2.3 Apache HTTP Server - high speed threaded mod
ii apache2-utils 2.2.11-2ubuntu2.3 utility programs for webservers
ii apache2.2-common 2.2.11-2ubuntu2.3 Apache HTTP Server common files

11. apt-get remove: Delete a Package

Use “apt-get purge” or “apt-get remove” to delete a package as shown below.
$ sudo apt-get purge apache2
(or)
sudo apt-get remove apache2
$
The following packages were automatically installed and are no longer required:
apache2-utils linux-headers-2.6.28-11 libapr1 apache2.2-common util1
Use 'apt-get autoremove' to remove them.
The following packages
linux-headers-2.6.28-11-generic apache2-mpm-worker libpq5 libap
rwill be REMOVED:
apache2
, 0 newly installed, 1 to remove and 26 not upgraded.
0 upgrade
d
Removing apache2 ...
  • apt-get remove will not delete the configuration files of the package
  • apt-get purge will delete the configuration files of the package

12. apt-get -u install: Upgrade a Specific Package

The following example shows how to upgrade one specific package.
$ sudo apt-get -u install apache2
Reading package lists... Done
Building dependency tree
... Done
apache2 is already the n
Reading state informatio
newest version.
ckages were automatically installed and are no longer required:
linux-headers
The following p
a-2.6.28-11 linux-headers-2.6.28-11-generic
Use 'apt-get autoremove' to remove them.
0 upgraded, 0 newly installed, 0 to remove and 26 not upgraded.

13. apt-get -u upgrade: Upgrade all Packages

To upgrade all the packages to it’s latest version, use “apt-get -u upgrade” as shown below.
$ sudo apt-get -u upgrade
The following packages will be upgraded:
  libglib2.0-0 libglib2.0-data libicu38 libsmbclient libwbclient0
  openoffice.org-base-core openoffice.org-calc openoffice.org-common
  openoffice.org-core openoffice.org-draw openoffice.org-emailmerge
  openoffice.org-gnome openoffice.org-gtk openoffice.org-impress
  openoffice.org-math openoffice.org-style-human openoffice.org-writer
  python-uno samba-common smbclient ttf-opensymbol tzdata
26 upgraded, 0 newly installed, 0 to remove and 0 not upgraded.

Package Managers:-

Yum (Yellow dog Updater, Modified) is mainly used in the rpm based distros, like redhat, fedora, centos and so on.

Some Yum Options:-


Escape the wild characters using the \.


yum install package
yum groupinstall "MySQL Database"
yum localinstall package.rpm


yum update package
yum groupupdate ""MySQL Database"


yum remove package
yum groupremove "MySQL Database"


yum list package - Search for specific package by name
yum grouplist - List all groups.
yum search mp3 - Searches the names, descriptions, summaries and listed package maintainers of all of the available packages to find those that match
yum provides libc.so - search for all packages that include files called libc.so


yum clean headers , yum clean packages , yum clean metadata , yum clean all - to redownload the indexes and cached files.


yum check update
yum upgrade

Uncompress multiple .zip .gz or .bz2


Uncompress multiple .zip .gz or .bz2

.zip

for file in *.zip; do unzip "${file}"; done
.gz

gunzip *.gz
.bz2

bunzip2 *.bz2
tar.gz

for file in *.tar.gz; do tar zxf "${file}"; done
tar.bz2

for file in *.tar.bz2; do tar jxf "${file}"; done

Shell script usage

If you use one of the snippets that uses a for loop in a script with an arbitrary number of archives, you may want to set the shell to use "nullglobs". For instance, normally *.tar.gz will evaluate to *.tar.gz when no files were found that match this wildcard, rather than evaluating to an empty string. As a result 'tar' is executed with this string as a parameter. To avoid this, you can request that the shell uses nullglobs with:

shopt -s nullglob
If no matches were found, the shell will return an empty string, and the for loop is terminated.

Customize Bash Prompt


User Specific Configuration

There are different approaches to customize the Bash Prompt. For user specific configuration edit ~/.bashrc and add your customization below the line '# User specific aliases and functions'
This example:

PS1='\u@\H:\w\$ ' 
will result in the following prompt:

user@hostname.domain.tld:/working/directory$
If you prefer a colorful prompt, try:

PS1='\[\033[02;32m\]\u@\H:\[\033[02;34m\]\w\$\[\033[00m\] '
A detailed description of color codes can be found here.
You can also display the hostname only, instead of the complete url by using 'h' instead of 'H' in the PS1 definition.

System-wide Configuration

System-wide configuration is done in /etc/bashrc. Comment out the default settings and add your customization below:

# [ "$PS1" = "\\s-\\v\\\$ " ] && PS1="[\u@\h \w]\\$ "
PS1='\u@\H:\w\$ ' 

XTerm

To set the XTerm window title, create a file called

/etc/sysconfig/bash-prompt-xterm
with the following content:

echo -ne "\033]0;${USER}@${HOSTNAME}:${PWD/#$HOME/~}\007"
and make it executable using:

chmod +x /etc/sysconfig/bash-prompt-xterm
If you only want to display the hostname instead of the complete url you can change:
${HOSTNAME}
to
${HOSTNAME%%.*}
which will strip all the information after the first '.'