linuxawy

mohamed salah el giar
faculty of Computers & Information Science
Computer Science Department
linux admin
python programmer
Contributing Authors
Recent Tweets @m7md_abosalah

linuxawy:

Unix-based Operating System provides powerful utilities that can select some fields or parts from configuration text files
this process can be done using cut command which used to select columns or fields from each line or inpu

SYNATX : cut -d” ” -fn which d represent delimiter and f…

Unix-based Operating System provides powerful utilities that can select some fields or parts from configuration text files 
this process can be done using cut command which used to select columns or fields from each line or inpu

SYNATX : cut -d” ” -fn which d represent delimiter and f represents field

Case1 :_ display the first column in /etc/passwd which has all users on the current system
[root@sys-engineer ~]# cut -d”:” -f1 /etc/passwd

where the first field can be expaned by deleimeter

Case2:_Display users who have logged on the system 
[root@sys-engineer ~]# who | cut -d’ ’ -f1 | uniq
user1
[root@sys-engineer ~]# 

Case3:_Tell how long the system has been running.
[root@sys-engineer ~]# uptime 
23:13:06 up  8:13,  4 users,  load average: 0.04, 0.09, 0.04
[root@sys-engineer ~]# uptime | cut -d’ ’ -f5
8:13,
[root@sys-engineer ~]# 


linux has more powerful utilities and commands can be used on files to split files or combine them in one single file 
split :- command which split a file into pieces of some files 
Syntax : split -option INPUT OUTPUT Prefix 
Options :- -l n used to split files into n-line chunks 
-b n used to split file with bytes of data- 
note : output files are named using output aa ,ab,ac, etc , added to the end of the file

CASE 1 :_ Create text file and make sequence of numbers from 1 to 300000 , then split this file to three files each file has 100000 line

[root@sys-engineer study]# seq 300000 > original
[root@sys-engineer study]# ll
total 1944
-rw-r--r-- 1 root root 1988895 Mar 12 21:54 original

to split the file named as original to three files , each file has 100000 lines

[root@sys-engineer study]# split -l 100000 original original_

here we have three new files named as original_aa ,original_ab and original_ac

[root@sys-engineer study]# ls -litotal 3888
1440989 -rw-r--r-- 1 root root 1988895 Mar 12 21:54 original
1441154 -rw-r--r-- 1 root root  588895 Mar 12 21:59 original_aa
1441158 -rw-r--r-- 1 root root  700000 Mar 12 21:59 original_ab
1452680 -rw-r--r-- 1 root root  700000 Mar 12 21:59 original_ac
[root@sys-engineer study]#

CASE 2: Create a block iso file with size of 400M and split it to new files : first file has 300M and second file has 100M

[root@sys-engineer study]# dd if=/dev/zero of=original.iso bs=1M count=400400+0 records in400+0 records out
419430400 bytes (419 MB) copied, 2.57668 s, 163 MB/s
You have new mail in /var/spool/mail/root
[root@sys-engineer study]#

[root@sys-engineer study]# split -b 300M original.iso file.iso_
[root@sys-engineer study]# ls -ll
total 819204
-rw-r--r-- 1 root root 314572800 Mar 12 22:13 file.iso_aa
-rw-r--r-- 1 root root 104857600 Mar 12 22:13 file.iso_ab
-rw-r--r-- 1 root root 419430400 Mar 12 22:09 original.iso
You have new mail in /var/spool/mail/root
[root@sys-engineer study]#

CASE 3 :_ To combine the splitted files into new file called final.iso

[root@sys-engineer study]# cat file.iso_aa file.iso_ab > final.iso
You have new mail in /var/spool/mail/root
[root@sys-engineer study]# ll
total 1228804
-rw-r--r-- 1 root root 314572800 Mar 12 22:13 file.iso_aa
-rw-r--r-- 1 root root 104857600 Mar 12 22:13 file.iso_ab
-rw-r--r-- 1 root root 419430400 Mar 12 22:19 final.iso
-rw-r--r-- 1 root root 419430400 Mar 12 22:09 original.iso
[root@sys-engineer study]#

to know the size of the new file called final.iso

[root@sys-engineer study]# du -h final.iso 401M   

final.iso

linuxawy:

Comparing Linux to Windows
The best way of highlighting the benefits of Linux and Unix is to compare them to what many people are using today - any of the various flavors of Microsoft Windows.

Linux is reliable The Blue Screen of Death doesn’t exist in the Linux world. Linux systems, just like…

m7md-abosalah:

In computing, tar (derived from tape archive and commonly referred to as “tarball”) is both a file format (in the form of a type of archive bitstream) and the name of a program used to handle such files. The format was created in the early days of Unix and standardized by POSIX.1-1988 and…

linuxawy:

Learn how to create partitions on a disk drive and how to format them for use on a Linux® system as swap or data space. You can use the material in this article to study for the LPI 101 exam for Linux system administrator certification, or just to learn about partitions and Linux filesystems for…