Generating files of any size
/dev/zerois A character special device, which infinitely returns the zero byte.
The above command would create a file called Junk.datathat is exactly 1MB in size. Let ' s go
Through the Parameters:ifstands for–inputfile, Ofstands for–outputfile, bsstands for
BYTES for a block, and countstands for the number of blocks of bsspecified to be copied.
DD If=/dev/zero of=junk.data bs=1m count=1
1+0 Records in
1+0 Records out
1048576 bytes (1.0 MB) copied, 0.00263553 s, 398 MB/s
Comm Command Demo:
[email protected] test]$ cat file1.txt file2.txt
1
2
3
4
1
2
4
5
[Email protected] test]$ Comm file1.txt file2.txt
1
2
3
4
5
[Email protected] test]$ Comm file1.txt file2.txt-1
1
2
4
5
[Email protected] test]$ Comm file1.txt file2.txt-2
1
2
3
4
[Email protected] test]$ Comm file1.txt file2.txt-3
3
5
[Email protected] test]$ Comm file1.txt file2.txt-3-1
5
-1 removes first column from output
-2 removes the second column
-3 removes the third column
[email protected] test]$ LL
Total 1052
-rw-rw-r--. 1 Hadoop Hadoop 08:34 all_txt_files.txt
-rw-rw-r--. 1 Hadoop Hadoop 8 Feb 03:29 file1.txt
-rw-rw-r--. 1 Hadoop Hadoop 8 Feb 03:29 file2.txt
-rw-rw-r--. 1 Hadoop hadoop 1048576 Feb 03:20 junk.data
-rw-rw-r--. 1 Hadoop Hadoop 02:06 mul_bank.txt
-rw-rw-r--. 1 Hadoop Hadoop 08:55 num.txt
Drwxrwxr-x. 2 Hadoop hadoop 4096 Feb 03:05 Sub
-rw-rw-r--. 1 Hadoop Hadoop 02:11 test.txt
"-"-if it is a regular file.
"D"-if it is a directory
"C"-for a character device
"B"-for a block device
"L"-if it is a symbolic link
"S"-for a socket
"P"-for a pipe
chmod u=rwx g=rw o=r filename
Here:
U =specifies user Permissions
G =specifies Group permissions
o =specifies Others permissions
chmod a+x filename
A statnd for all.
Read,write,and Execute permissions has a unique octal numbers as follows:
R--=4
-w-=2
--x=1
Touch is a command that can create blank files or modify the timestamp of files if they
Already exist.
Symbolic links is just pointers to other files.
Ln-s targetfilename (directory) link_name
Ln-s Test.txt Test_link.txt
counting number of lines, words, and characters in a file
$ wc-l File # count number of lines as follows:
$ wc-w File #count words number
$ head-10 filename
$ tail-10 filename
Head used to get the first n lines of the file.
Tail is used to get the last n lines of the file.
Linux Shell basic3 dd WC comm chmod ls