Unix For Testers
Unix System Architecture
Unix File System Structure
Absolute and Relative Path
Basic Unix Commands
cal command in Unix
who command in Unix
date command in Unix
clear command in Unix
more command in Unix
whoami command in Unix
uname command in Unix
man command in Unix
echo command in Unix
Unix File System Commands
ls command in Unix
cat command in Unix
cp command in Unix
mv command in Unix
pwd command in Unix
cd command in Unix
mkdir command in Unix
rmdir command in Unix
rm command in Unix
touch command in Unix
dirname command in Unix
tar command in Unix
Unix Links(ln)
Hard Link
Soft Link
Regular Expressions
Basic Regular Expressions
Interval Regular Expressions
Pipes and Filters
Unix Text Processing Commands
cmp command in Unix
diff command in Unix
comm command in Unix
cut command in Unix
Paste command in Unix
head command in Unix
tail command in Unix
wc command in Unix
sort command in Unix
grep command in Unix
Process Related Command
top command in Unix
ps command in Unix
nice command in Unix
Kill command in Unix
nohup command in Unix
time command in Unix
File Tranfer Commands in Unix
file transfer using scp command
file transfer using rlogin command
file transfer using telnet command
ssh(Secure Shell) command in Unix
ftp file transfer command
sftp file transfer command
chmod command in Unix
File Permission and File Security in Unix
File System Commands in Unix
This article aims to familiarize with the basic file system commands in Unix that helps to work with files and directories
touch command in Unix
The touch command is used to update the timestamps on existing files and directories as well as creating new, empty files.
-
-
-
- Updates the access and modification times.
- It is used to create a file without any content.
- This command can be used when the user doesn’t have data to store at the time of file creation.
-
-
Syntax:
 touch [-amc] [mmddhhmm[yy]] files
 touch filename: When touch command is used without any options, if the file name specified as an argument doesn’t exist touch will create a new file.
touch -a file1: This command is used to change access time of file1.
touch file1 file2 file3Â :Multiple files with name file1, file2 ,file3 are created at the same time
Examples of the cat command in Unix are:
-
- create or modify timestamp of file using touch command
touch file1
2. To create or modify multiple files at once, specify the file names as arguments
touch file1 file2 file3
dirname command in Unix
-
-
-
- Strips non-directory suffix from filename
-
-
Syntax:
dirname NAME
dirname OPTION
for more details on dirname refer here
tar command in Unix
The tar command creates tar files by converting collection of files into an archive. It also can extract tar archives and display list of the files included in the archive.
-
-
-
- Archiving files
- File require archiving in order to compress data
- Reduce the storage space.
-
-
Syntax:
tar [OPERATION_AND_OPTIONS] [ARCHIVE_NAME] [FILE_NAME(s)]
OPERATION: Only one operation argument is allowed and required. The most frequently used operations are: create (-c) – Create a new tar archive. extract (-x) – Extract the entire archive or one or more files from an archive. list (-t) – Displays list of the files included in the archive
ARCHIVE_NAME: The name of the archive.
FILE_NAME(s): A space-separated list of filenames to be extracted from the archive. If file name is not provided, the entire archive is extracted.
Option |
Use |
-c |
create |
-t |
List all files |
-x |
Extract all |
-v |
verbose |
-z |
Create a Zip file |
-r |
Append |
-cvf |
Create archive from files |
-tvf |
List all files in archive.tar |
-xf |
Extract all files in archive.tar |
-cvzf |
Create a compressed gzip archive file |
-rvf |
Append a file to the existing archive |
Example:Â
-
-
-
- command creates a tar file called file.tar which is the Archive of all .dat files in the current directory.
-
-
$ tar -cvf file.tar *.c
2. Extracting files from Archive using option -xvf : This command extracts files from Archives.
$ tar -xvf file.tar
3. List all the archive files without extracting
$ tar -tvf file.tar
4. List the content of the gzipped archive, without extracting
$ tar -tvzf file.tar
5. Update existing tar file in Linux
$ tar rvf file.tar *.c
Recommended Articles:
Unix For Testers
Unix System Architecture
Unix File System Structure
Absolute and Relative Path
Basic Unix Commands
cal command in Unix
who command in Unix
date command in Unix
clear command in Unix
more command in Unix
whoami command in Unix
uname command in Unix
man command in Unix
echo command in Unix
Unix File System Commands
ls command in Unix
cat command in Unix
cp command in Unix
mv command in Unix
pwd command in Unix
cd command in Unix
mkdir command in Unix
rmdir command in Unix
rm command in Unix
touch command in Unix
dirname command in Unix
tar command in Unix
Unix Links(ln)
Hard Link
Soft Link
Regular Expressions
Basic Regular Expressions
Interval Regular Expressions
Pipes and Filters
Unix Text Processing Commands
cmp command in Unix
diff command in Unix
comm command in Unix
cut command in Unix
Paste command in Unix
head command in Unix
tail command in Unix
wc command in Unix
sort command in Unix
grep command in Unix
Process Related Command
top command in Unix
ps command in Unix
nice command in Unix
Kill command in Unix
nohup command in Unix
time command in Unix
File Tranfer Commands in Unix
file transfer using scp command
file transfer using rlogin command
file transfer using telnet command
ssh(Secure Shell) command in Unix
ftp file transfer command
sftp file transfer command
chmod command in Unix
File Permission and File Security in Unix