You need to use the combinations of the following Linux or Unix-like system commands:
- [donotprint]
- sed command
- cat command
- less command
- awk command
- mapfile command (Bash v4.x only)
Tutorial details | |
---|---|
Difficulty | Easy (rss) |
Root privileges | No |
Requirements | None |
Time | 1m |
To display 1 to 10 lines from /etc/passwd file and number all output lines, enter:
sed -n "1,10p" /etc/passwd | cat -n
Sample outputs:
sed -n "50,200p" /etc/passwd | less -N
The following example use the head command to display first 10 lines of /etc/passwd file:
head +10 /etc/passwd | cat -n
Sample outputs:
1 ==> /etc//passwdDisplay 10-20 lines using head and tail combo as follows:
head -20 /etc/group | tail -n 10 | cat -nSample outputs:
1 nobody:*:-2: 2 nogroup:*:-1: 3 wheel:*:0:root 4 daemon:*:1:root 5 kmem:*:2:root 6 sys:*:3:root 7 tty:*:4:root 8 operator:*:5:root 9 mail:*:6:_teamsserver 10 bin:*:7:
Category | List of Unix and Linux commands |
---|---|
File Management | cat |
Firewall | Alpine Awall • CentOS 8 • OpenSUSE • RHEL 8 • Ubuntu 16.04 • Ubuntu 18.04 • Ubuntu 20.04 |
Network Utilities | dig • host • ip • nmap |
OpenVPN | CentOS 7 • CentOS 8 • Debian 10 • Debian 8/9 • Ubuntu 18.04 • Ubuntu 20.04 |
Package Manager | apk • apt |
Processes Management | bg • chroot • cron • disown • fg • jobs • killall • kill • pidof • pstree • pwdx • time |
Searching | grep • whereis • which |
User Information | groups • id • lastcomm • last • lid/libuser-lid • logname • members • users • whoami • who • w |
WireGuard VPN | Alpine • CentOS 8 • Debian 10 • Firewall • Ubuntu 20.04 |
Hi,
thanks
tail command display last ten lines
it did not for me