File Types In Linux
0 comments 2/15/2010 03:22:00 PM Posted by Meghana M BhombhoreLabels: Basics, File System, Tutorials
"How many types of files are there and what are they?" This is a common question to every person who started learing Linux.
Why is this so much important to know file types?
Ans : This is because Linux will consider every thing as files. The Answer to this question is little bit confusing with different answers.
Let me put it in this way to clarify. By default Unix have only 3 types of files..
They are.
1. Regular files
2. Directory files
3. Special files(This is the file type who is the culprit for different answers. This catagory is having 5 sub types.)
So Total file types in Linux are 7. Remeber I am saying in linux there are only 7 types of files but if it comes to unix it is 8 types.
Here are those files. And you can see the file type indication at leftmost part of “ls -l” command
1. Regular file(-)
2. Directory files(d)
Special files
3. Block file(b)
4. Character device file(c)
5. Named pipe file or just a pipe file(p)
6. Symbolic link file(l)
7. Socket file(s)
For your information there is one more file called door files(D) which is present in Sun Solaris. A door is a special file for inter-process communication between a client and server(so total 8 types in Unix machines.).
Regular files : These are the files are indicated with "-" in ls -l output. And these files are.1. Readable files or
2. A binary files or
3. Image files or
4. Compressed files etc.
How to create them?
Ans : Use touch command.
Example listing of regular files :-rw-r--r-- 1 krishna krishna 20986522 2010年01月31日 13:48 test.wmv
-rw-r--r-- 1 krishna krishna 173448 2010年01月30日 21:20 Transformers-Teaser-Wallpaper-310.jpg
-r-xr-xr-x 1 root root 135168 2009年12月12日 19:14 VIDEO_TS.VOB
-rw-r--r-- 1 krishna krishna 2113536 2009年12月01日 13:32 Aditya 365 – Janavule.mp3
-rwxrwxrwx 1 root root 168 2010年02月14日 14:12 xyz.sh
Directory files : These contains the name and location of files/folders/special files stored on a physical device. And this type of files will be in blue in color.
How to create them?
Ans : Use mkdir command
Example listing of directories.drwxr-xr-x 2 surendra surendra 4096 2010年01月19日 18:37 bin
drwxr-xr-x 5 surendra surendra 4096 2010年02月15日 18:46 Desktop
drwxr-xr-x 2 surendra surendra 4096 2010年01月18日 14:36 Documents
drwxr-xr-x 2 surendra surendra 4096 2010年02月13日 17:45 Downloads
Block files : These files are hardware files most are present in /dev
How to create them?
Ans : Use fdisk command or create virtual partition.
Example listing of Block files(for you to see these file, they are located in /dev).
brw-rw---- 1 root disk 8, 1 2010年02月15日 09:35 sda1
brw-rw---- 1 root disk 8, 2 2010年02月15日 09:35 sda2
brw-rw---- 1 root disk 8, 5 2010年02月15日 09:35 sda5
Character devices files : Provide only a serial stream of input or output.
Example listing of character files(located in /dev)
crw-rw-rw- 1 root tty 5, 0 2010年02月15日 16:52 tty
crw--w---- 1 root root 4, 0 2010年02月15日 09:35 tty0
crw------- 1 root root 4, 1 2010年02月15日 09:35 tty1
Pipe files : The other sort of pipe is a “named” pipe, which is sometimes called a FIFO. FIFO stands for “First In, First Out” and refers to the property that the order of bytes going in is the same coming out. The “name” of a named pipe is actually a file name within the file system. --www.linux.com
How to create them?Ans : Use mkfifo command.
Example listing of pipe files
prw-r----- 1 root root 0 2010年02月15日 09:35 /dev/.initramfs/usplash_outfifo
prw-r----- 1 root root 0 2010年02月15日 09:35 /dev/.initramfs/usplash_fifo
prw------- 1 syslog syslog 0 2010年02月15日 15:38 /var/run/rsyslog/kmsg
Sybolic link files : These are linked files to other files.
How to create them?
Ans : use ln command
Example listing of linked files
lrwxrwxrwx 1 root root 24 2010年02月15日 09:35 sndstat -> /proc/asound/oss/sndstat
lrwxrwxrwx 1 root root 15 2010年02月15日 09:35 stderr -> /proc/self/fd/2
lrwxrwxrwx 1 root root 15 2010年02月15日 09:35 stdin -> /proc/self/fd/0
lrwxrwxrwx 1 root root 15 2010年02月15日 09:35 stdout -> /proc/self/fd/1
Socket files : A socket file is used to pass information between applications for communication purpose
How to create them?
Ans : You can create a socket file using socket() system call avialable under
Example
int sockfd = socket(AF_INET, SOCK_STREAM, 0);
You can refer to this socket file using the sockfd. This is same as the file descriptor, and you can use read(), write() system calls to read and write from the socket.
Example listing of socket files.
srw-rw-rw- 1 root root 0 2010年02月15日 09:35 /dev/log
srwxrwxrwx 1 root root 0 2010年02月15日 10:07 /var/run/cups/cups.sock
srwxrwxrwx 1 root root 0 2010年02月15日 09:35 /var/run/samba/winbindd_privileged/pipe
srwxrwxrwx 1 mysql mysql 0 2010年02月15日 09:35 /var/run/mysqld/mysqld.sock
A tip for you guys.
How to find your desired type of a file ?Ans : Use find command with -type option.
For example if you want to find socket file, just use below command.find / -type sIf you want to find linked file then how?Find / -type l
Thats it.. You got it.. :) Enjoy reading..
Webmin
0 comments 1/23/2010 09:22:00 PM Posted by Surendra Kumar AnneLabels: Applications, Softwares and Downloads, Tutorials
Webmin is a web based administration tool to do daily admin activities.
by using this tool we can configure.
1. User management
2. Disk management such as RAID, LVM etc.
3. Disk Quotas
4. Services/Servers such as apache, DNS, PHP, Mysql etc
5. Will allow us to confgire/controll many systems through single interface(ie through a web browser).
For example you want to controle your linux machine remotly through no Linux machines such as windows or a mobile device. We can do the system admin activity through a web broswer. Some time I used to login to my linux server which is located in SJ, USA through my Sonyerricson C702 mobile phone to take backups.
Installation in Ubuntu
If you like to install and update Webmin via APT, edit the /etc/apt/sources.list file on your system and add the line :
deb http://download.webmin.com/download/repository sarge contrib
You should also fetch and install a GPG key with which the repository is signed, with the
Commands :
cd /root
wget http://www.webmin.com/jcameron-key.asc
apt-key add jcameron-key.asc
You will now be able to install with the commands :
apt-get update
apt-get install
Installation in Redhat/Fedora
#yum install perl
#yum install webmin
After installation webmin server will work on localhost at 10000 port, which is default port for webmin.
To access webmin through your browser
http://localhost:10000
Why a unix admin should know about Webmin?
Ans : Webmin is a one stop to administer your machine we can manage allmost all the servers, disk management, user management etc. Which is supported on different operating systems, recently it is supporting Windows too(with limitations) .
Which are the operating systems we can install webmin to administer the system?
Ans : Bcz it is supported in many unix and linux flavors such as
1. Redhat, Fedora, SuSE and Mandrake through RPM packages
2. Debian and Ubuntu through .deb packages
3. HPUX, FreeBSD and Slackware Linux through source code(eg: .tar.gz and .tar.bz)
4. MS Windows through exe
How To Install SSH Server In Ubuntu Linux OS?
0 comments 1/18/2010 06:58:00 PM Posted by Surendra Kumar AnneLabels: Basics, How-To's, Tutorials
By default in Ubuntu SSH(Secure SHell) server is not installed. This is a big problem when you want to access the Ubuntu machines from other machines we can not access. In this post I will show you how to install and SSH server and give you some examples how to use ssh.
Installing ssh server in ubuntu
#apt-get install openssh-server
Once you install now try to login to that machine
#ssh 0
Note : In this example i am login to same machine, which i am going to check whether service is running or not. We should get successfully login for the above command which will prompt for password.
SSH examples:
Example1 : Login to a remote machine using its hostname
#ssh servername
Note : This will allow us to login to remote server on default ssh port(22)
Example2 : Login to a remote machine using its IP add
#ssh 192.168.0.1
Example3 : Login in to a remote machine which uses different port for running ssh server
#ssh 192.168.0.1 2010
Note : Here SSH server is running on 2010 port(some times this is good practice to secure the system).
Example4 : Login to a remote machine with different user
#ssh user@192.168.0.1
Example5 : Executing commands on remote machine with out login to the machine.
#ssh 192.168.0.1 "ls -l"
Note : This command will execute "ls -l" command on remote host:192.168.0.1 and gives the output on a local machine.
SSH server is a big concept which can not be dealt with in one post. Will try to write another post on SSH server.
Mount NTFS Partations In Linux Machines.
0 comments 1/18/2010 06:38:00 PM Posted by Surendra Kumar AnneLabels: How-To's, Tutorials, Windows
How to mount NTFS(New Technology File System) partations in Linux?
Ans : By default we can not mount ntfs partations, to do that we have two options
1.Compiling kernle, click here to see how to compile a kernel.
2.Install Fuse tool and then mount the ntfs partation's.
Let us start how to install fuse and then mount ntfs partations
Step1 : Install the following softwares
#yum install fuse
#yum install dkms-fuse
#yum install fuse-ntfs-3g
If you dont have yum and want to install through rpm, then you have to download the above three packages and install them through rpm command.
For this you need to download correct versions of above packages from dag weirs repository.
Repository link is as following:
http://dag.wieers.com/rpm/packages/
Step2 : After installing above packages, you need to ensure that "fuse" module is loaded or not, run the below command
#lsmod grep fuse
Step3 : If this is not showing any thing, we have to load this fuse module.
#modprobe fuse
Step4 : After loading fuse module, run following command to mount ntfs filesystem in linux system
# mount -t ntfs-3g /dev/hdb1 /media
Above command will mount ntfs partition in R/W mode.
How To Access/Change Password For Root Account In Ubuntu
0 comments 1/10/2010 08:43:00 AM Posted by Meghana M BhombhoreLabels: Basics, How-To's, Tutorials, Ubuntu
How To View CHM Files In Linux?
0 comments 12/31/2009 08:43:00 AM Posted by Surendra Kumar AnneLabels: Applications, How-To's, Softwares and Downloads, Tutorials
If you are a book worm then defiantly you will know what is a CHM file?
For those who don't know the CHM files let me explain it. CHM file is a compiled HTML files/document(s) in to a e-book kind so that we can view and index easily. This formate is the proprietary of Microsoft and by default the application to view CHM files in windows is installed.
We have to install CHM file viewer. There are so many applications to achieve this such as
* gnochm
* CHMsee
* FBReader
Qt
* Okular
* kchmviewer
* Kchm
* chmcreator
Other
* xCHM
* Archmage
* DisplayCHM
* CHM Reader Firefox addon
In this post I will show you how to install gnochm application to view CHM files.
#rpm -ivh libchm1.0.40-1.i386.rpm
#rpm -ivh python-chm.0.8.4-1.i386.rpm
#rpm -ivh 0.9.11-2.i386.rpm
Installing gnochm in Ubuntu
#apt-get install gnochm
How To View PDF Files/Documents In Linux?
0 comments 12/29/2009 07:01:00 PM Posted by Surendra Kumar AnneLabels: How-To's, Softwares and Downloads, Tutorials
When i started using Linux. Big question was in my mind is whether i can view PDF(Portable Document Format) files or not? but as Linux prove to be "get your work done in many ways". a classic example is PDF viewers in Linux.
Its very much easy to install PDF viewer
You can install either
xpdf
For Red-hat flavours
For Ubuntu
apt-get install xpdf
or
kpdf
For Redhat flavors
rpm -ivh kpdf.ver.i386.rpm
apt-get install kpdf
or
For Redhat/Ubuntu flavors
http://ardownload.adobe.com/pub/adobe/reader/unix/9.x/9.2/enu/AdbeRdr9.2-1_i486linux_enu.bin
Download Acrobat Reader from the above link and install
./AdbeRdr9.2-1_i486linux_enu.bin
Enjoy reading PDF documents. If you are having any issues in installing the packages please feel free to comment.
Access Linux From Windows Through Virtual Network Computing(VNC)
0 comments 12/18/2009 08:35:00 AM Posted by Meghana M BhombhoreLabels: How-To's, Tutorials
VNC(Virtual Network Computing) is an open source utility to access any remote host through GUI. In this post we will see how to login to Linux server from a windows machine.
Step1 : Install VNCserver on Linux machine
#rpm –ivh vnc-server-4.1.2-9.el5.i386.rpm
Step2 : Start VNC server now
#service vncserver restart
#vncserver
Note and this is very important :
1. Now it will ask for a password to access the Linux server through VNC viewer and this password is for root user to login from any machine through VNC.
2. If you want to access GUI for a particular user, first login to that user account and execute vncserver command. When you execute this command in the user login it will ask for a password, and this password is for the user to login from remote host through VNC to the Linux server.
3. For security reasons please give different password for accessing Linux through VNC other than your password to login to the Linux machine. If you remember and understand these points your goal is almost completed.
Step3 : Make sure that your Linux server is running in run level 5/GUI. Any of the below command will start your GUI service in Linux.
#init 5
Or
#startx
Step4 : By default Linux will not allow login to GUI. We have to configure VNC server to allow user to login through GUI. For configuration VNC server edit ~/.vnc/xstartup file
#vi ~/.vnc/xstartup
Uncomment these below two lines in the file, then save and exit the file.
unset SESSION_MANAGER
exec /etc/X11/xinit/xinitrc
Step5 : Now once again start the vncserver( just execute vncserver command) in user account, so that it will continuously on. When you execute the command it will provide valuable information how to access the server. The clipped output is as follows, here if you see its saying to access the GUI you have to give hostname as rp2.test.com:2
[kumar@rp2 ~]$ vncserver
New 'rp2.test.com:2 (kumar)' desktop is rp2.test.com:2
Starting applications specified in /home/kumar/.vnc/xstartup
Log file is /home/kumar/.vnc/rp2.persistent.co.in:2.log
Step6 : Now login to Windows machine where VNC viewer is installed and try to access the Linux server.
Some FAQ :
1.What is the port no for VNC server?
Ans : 5800+
2.Which are the other tools which will work same as VNC?
Ans : VNC, TS, Citrix, Reflection etc.
3.What is the significance of rdesktop?
Ans : Rdesktop is an utility to access windows machines from Linux.
Please comment regarding this post:-)
How To Open Big Size File Using VI Editor?
0 comments 12/03/2009 07:44:00 AM Posted by Meghana M BhombhoreLabels: How-To's, Tutorials
How to Open/edit large files using VI?
Ans : Some time you will get message like file is too large to open with VI editor or some sort of other error messages like.
For Example : Warning: Tmp file too large
This doesn't mean that you don't have enough space to open the file in /var/tmp (this is default VI editor temp location). This is because VI is having limitation in opening big files which is more than 9070000 character or file of size 2GB.
This is a warning message you get from vi (i.e. the ex family of editors) that it can not track your changes in the temporary files, the editor maintains during an edit session. So when ever using VI editor remember following things(These are from VI editor manual).
1.If the editor crashes (i.e. system halts, or accidental process termination), a preserve file cannot be created and you will not be able to recover your changes via the recover feature(vi -r filename is used to recover a file from .swp file).
2.In addition, while editing a very large files and vi fails to come up in visual mode, do not write this file (:w) since it may be truncated/crashed. You should quit (:q!) and open the file with csplit utility to divide the big file into smaller smaller files and edit(I dont suggest this as it is very much advanced to normal users).
3.To open files less than 2GB use following procedure
Step1 : Just execute vi command with out any file
#vi
Step2 :
In the command mode,
type :set directory="any directory with enough free space"
Step3 :
Now open the file using
:e "file name"
Through this way we can avaoid vi crashing.
Some utilities which is used to view large files are.
a.cat filename more
b.tail filename
c.head filename
d.more filename
e.less filename
To open a file at desired line
head -n filname tail -1
Please comment your thoughts regarding this post:-)
Surendra's DIG Notes
0 comments 11/24/2009 09:39:00 AM Posted by Surendra Kumar AnneLabels: DNS Servers, How-To's, Server Troubleshooting, Tutorials
2. DIG can work on command line or as well in batch mode
3. DIG supports IDN convections too.
4. DIG is more advanced than older tools such as nslookup and host commands.
5. DIG output have so much information than any other tool, such as Question/Answer/Authority sections(which we are going to discuses in this post)
#dig hostname
Example :
[root@ts6741 ~]# dig www.google.com
; <<>> DiG 9.3.3rc2 <<>> www.google.com
; (1 server found)
;; global options: printcmd
;; Got answer:
;; ->>HEADER<<- opcode: QUERY, status: NOERROR, id: 52434
;; flags: qr aa rd ra; QUERY: 1, ANSWER: 1, AUTHORITY: 3, ADDITIONAL: 3
;; QUESTION SECTION:
;www.google.com. IN A
;; ANSWER SECTION:
http://www.google.com/. 43200 IN A 200.99.187.2
;; AUTHORITY SECTION:
http://www.google.com/. 43200 IN NS ns2.google.com.
http://www.google.com/. 43200 IN NS ns3.google.com.
http://www.google.com/. 43200 IN NS ns1.google.com.
;; ADDITIONAL SECTION:
ns1.google.com. 43200 IN A 222.54.11.86
ns2.google.com. 43200 IN A 220.225.37.222
ns3.google.com. 43200 IN A 203.199.147.233
;; Query time: 1 msec
;; SERVER: 222.54.11.86#53(222.54.11.86)
;; WHEN: Wed Nov 18 18:31:12 2009
;; MSG SIZE rcvd: 152
[root@ts6741 ~]#
#dig –x ipadd
#dig –x 192.56.78.1
Usage3 : Digging with specified DNS server. Let me put it in this way. My dns server is not working properly and I want to test some server details, for this DIG will allow you to provide a DNS sever so that DIG will get information about the required system from that DNS server. We can provide DNS server by using @ symbol as shown below.
#dig @ns-server hostname
Note : Here in this example my dig will not check /etc/resolve.conf file for default DNS server entry, it will just request details of http://www.google.com/ from a outside world DNS server ie 223.125.43.67
#dig @223.125.43.67 -p 2345 www.google.com
Note:here 223.125.43.67 is the DNS server and port 2345 where that DNS service is running.
Usage6 : To get mail server details
#dig mx www.google.com
Note : This will provied all the mail servers in google.com
Note : This will provide all the Name Server records.
Please comment your thoughts regarding this post:-)
NMAP With Examples
0 comments 11/23/2009 05:37:00 AM Posted by Surendra Kumar AnneLabels: How-To's, Network Monitoring, Tutorials
- NMAP abbreviation is network mapper
- NMAPis used to scan ports on a machine, either local or remote machine (just you require ip/hostname to scan).
- NMAPis can be installed on windows, Sun Solaris machines too.
- NMAPcan be used to scan large networks, remember I am saying large networks.
- NMAPcan be used to get operating system details, uptime, software used for a service and its version no, vender of network card and uptime of that system too(Don’t worry we will see all these things in this post.
- Please do not try to use NMAP on machines which you don’t have permission.
- Can be used by hackers to scan for systems for venerability.
- Just a funny note : You can see this NMAP used by trinity in Matrix-II, when she tries to hack in to electric grid super computer.
Example1 : Using NMAP in normal way, i.e. to scan a particular system for open ports
#nmap –p 22 hostname
This will scan for 22 port is open on a host or not. And here –p indicates port.
#nmap –F hostname
-F is for fast scan and this will not do any other scanning like IP address, hostname, operating system, and uptime etc. It’s very much fast as it said in man pages.
Example4 : For scanning only TCP ports
#nmap –sT hostname
Here s is for scanning and T is for only scanning of TCP ports
Example5 : For scanning only UDP ports
#nmap –sU hostname
Here U indicates UDP port scanning
Exmaple6 : Scanning for ports and to get what is the version of different services running on that machine
#nmap –sV hostname
V indicates version of each network service running on that host
Example7 : To check which protocol is supported by the remote machine
#nmap –sO hostname
Example8 : To scan a system for operating system and uptime details
# nmap -O hostname
-O is for operating system scan along with default port scan
Example9 : Scanning a network
#nmap networkID/subnetmask
For the above command you can try in this way
#nmap 192.168.0.0/24
Some sites to refer (not for practical examples, but for to get good concept):
nmap.org : official site for our NMAP
en.wikipedia.org/wiki/Nmap
Linux Virtual File System
0 comments 11/07/2009 06:20:00 AM Posted by Meghana M BhombhoreLabels: Administration, Disk-Mgmt, How-To's, Tutorials
Can we create a file system (i.e. formatting a drive/partition) with in a file system?
Looks little bit strange is int it? So follow me I will show you how to create a virtual partition and file system within a partition.
Step1 : Create a empty file with /dev/zero with size equal to 50Mb.
#dd if=/dev/zero of=/temp/vf0 count=102400
Note :
1. By default "dd" command(dataset definition) uses block of 512bytes so the size will be 102400*512=52 428 800=~50MB
2. /dev/zero is a device files which will be used create a file which conations "0" i.e. an empty file.
Clipped output:
[root@test6 ~]# dd if=/dev/zero of=/temp/vf0 count=102400
102400+0 records in
102400+0 records out
[root@test ~]# ls -lh /temp/vf0
-rw-r--r-- 1 root root 50M Nov 7 12:08 /temp/vf0
Step2 : Create ext3 file system for this virtual partition.
#mkfs -t ext3 /temp/vf0
Here it will ask "do you want to format the file or not"?, just say yes.
Step3 : Now we have to create a mount point (nothing but a directory) and mount the created partition.
# mkdir /virtdrive
# mount -o loop=/dev/loop0 /temp/vf0 /virtdrive
Note:
/dev/loop is special hardware device used to mount ISO files and virtual file systems. In Linux there are total 8 loop devices numbering from 0 to 7. So you can mount only 8 ISO files/virtual file systems by default.
Step4 : Edit /etc/fstab file to mount permanently, so that it be auto mounted at boot time too. Specify following entry in fstab file.
/temp/vf0 /virtdrive ext3 rw,loop=/dev/loop0 0 0
Step5 : Specify the fstab changes to kernel.
#mount -a
Step6 : Conform Weather mounting happen perfectly or not.
Way1 :
#cat /etc/mtab
Way2 : Change the directory to mount point you have to see lost+found folder
[root@test ~]# cd /virtdrive/
[root@test virtdrive]# ls
lost+found
[root@test virtdrive]#
Please comment your thoughts regarding this post:-)
RSYNC --The tool every Admin should know
0 comments 8/24/2009 01:28:00 AM Posted by Surendra Kumar AnneLabels: Administration, Backup/Restore-Mgmt, File Sharing Servers, How-To's, Tutorials
Let us list advantages of this command then we will know how to configure it.
Advantages of rsync :
- This tool will keep both the destination and source folder synced.
- rsync is fast, because it will not copy entire data every time it got synced, it just copes the date which got changed from previous copy.
- For security reasons, rsync will support ssh to transfer data between two machines.
- rsync is used to download RPM updated repository to local machine.
Configuration : rsync
Some points to be remembered when dealing with rsync
- This utility is the part of xinetd so there is no special package for this.
- When we are doing rsync between two systems, both the systems should be configured to allow rsync connections.
- rsync uses 873.
#yum install xinetd
Step2 : Configure rsync to allow connections, the configuration file for rsync is located in /etc/xinetd.d
#cd /etc/xinetd.d
#vi rsync
# default : off
# description: The rsync server is a good addition to an ftp server, as it \
# allows crc checksumming etc.
service rsync
{
disable = yes
socket_type = stream
wait = no
user = root
server = /usr/bin/rsync
server_args = --daemon
log_on_failure += USERID
}
In this configuration file just change disable = yes to no, then save the file and exit. Here is the updated configured file.
# description: The rsync server is a good addition to an ftp server, as it \
# allows crc checksumming etc.
service rsync
{
disable = no
socket_type = stream
wait = no
user = root
server = /usr/bin/rsync
server_args = --daemon
log_on_failure += USERID
}
Step3 : Start the rsync service, so how to do it? As i mention earlier that rsync is a part of xinetd service so just restart the xinetd service.
#service xinetd restart
Step4 : Permanently on the service
#chkconfig rsync --levels 345 on
Same configurations should be done on the other system too, in order to rsync executed properly.
FILE'S and FOLDER'S Part-2
0 comments 8/12/2009 02:20:00 AM Posted by Surendra Kumar AnneLabels: Basic-Commands, Basics, How-To's, Tutorials
FILES & FOLDERS PART-II
CREATING FOLDERS :
Cmd4a : Creating a single folder.
Example :
#mkdir test
Cmd4b : Creating multiple folders at a time
#mkdir 1{1,2,3}
This command will create folders with name 11,12,13. You can see weather this folders are created or not by using ls or dir command.
Cmd4c : Creating multiple directories and sub directories at a time. This is very much advanced and very much useful command. Some times we have to create a directory structure with sub directories in it. Which are not exist before.
For example I want to create the directory structure as below
/test
/ \
/ \
/ \
user1 user2
/ \ / \
/ \ / \
/ \ / \
apple goa pine tom
So if I want to create these many folders at a time i have to execute the following commands.
First i have to create test directory, then I have to change the directory to it and the create two more directories as user1 and user2 and so on as below.
#mkdir test
#cd test
#mkdir user1
#mkdir user2
#cd user1
#mkdir apple
#mkdir goa
#cd ..
#cd user2
#mkdir pine
#mkdir tom
So you see these many commands i have to execute to create that directory structure. But in linux, its very much easy if you know this option with mkdir command. Execute the mkdir command with -p option it will create subdirectories though they didnt exist.
#mkdir -p test/{user1/{apple,goa}, user2/{pine,tom}}
Thats it you are done. This will create all the folders and sub folders.
Plese visit for remaining posts on files and folders operations..
Labels: Basic-Commands, Basics, How-To's, Tutorials
Cmd1 : Use touch command to create empty file's
#touch test
#touch {1,2,3}{4,5,6}
The above command will create files with 14,15,16,24,25,26,34,35,36 as names by using this you can create n number of files at a time.
For checking weather your files/folders are created you can use ls command.
Please check linuxnix.com for updates.
Cmd2 : Creating files using cat command in combination of output redirecting operator(>)
#cat > filename
Once enter this command you have to enter the content of the file and once you finish it just press Ctrl+dthis will save the file. Use again ls command to display the files created.
Cmd3 : Creating a file with any editor(either VI,emacs etc)
#vi filename
Once you execute this command the file will be opened and in order to enter any data we have to first press i to go in to insert mode. Once you type the content in to the file just press esc and :wq to save and quit the file.
Have look at other related posts too.