TRΓ„W🀟 Profile picture
Nov 17, 2021 β€’ 27 tweets β€’ 9 min read β€’ Read on X
Basic Linux 🐧CommandsπŸ“œ For Text Manipulation

A thread🧡

Hello everyoneπŸ‘‹, Today I'll be doing a quick, easy to follow thread🧡 on basic Linux commands for text manipulation.
#infosec #cybersecurity #Linux
1. Echo🐧
The echo command is used to display line of text to the standard output(stdout).
2. Cat🐧
The cat command is used concatenate files and print their contents on the standard output. In other words it's just used to display the contents of a file.
3. Paste🐧
The paste command is similar to the cat command, it merges lines together in a file and make it a one huge single line.
4. Head🐧
This command is used to display the first part of a file. Let's say we have a very long file and you just wanted to see the first couple of lines in this text file.
Well, this is when the head command comes into play, by default the head command will show you the first 10 lines in a file.
You can also modify the line count to whatever you want, for example let's say I wanted to see the first -3 lines instead. From the picture below the -n stands for the number of lines we want to display.
5. Tail🐧
Similar to the head command, the tail command lets you see the last 10 lines of a file by default. But you can always change it as well and specify the number of lines you want to display. Here I have chose to display the last 3 lines.
6. Rev🐧
This command reverses lines characterwise.
7. Tac🐧
Similar to the cat command, the tac command concatenate and print files contents in reverse order. You can tell from the name that this command is the reverse version of the popular cat command.
8. Sort🐧
The sort command is very useful for sorting files, text lines.
The sort command also has the capability of sorting in reverse order
With sort command you also can sort according to string numerical value.
9. tr (Translate)🐧
The tr (translate) command allows you to translate a set of characters into another set of characters. It's also used to squeeze or delete characters from standard input and display the result to standard output.
On above screenshot we converted all the a -> A, b -> B and c -> C . Note that the number of characters on the first set should be equal to the number of characters on the second set. Let's try another example of translating characters.
Here is another example for deleting characters with tr
The tr command also supports the intimidating πŸ˜„regular expressions. Let's try an example of translating all lower case characters to uppercase characters using regex.
10. Uniq (Unique)🐧
The uniq (unique) command is another useful tool for parsing text. It's used to omit/remove duplicates from a file, hence the name uniq.
11. wc🐧
Word Count(wc) is used to print newline, word, and byte counts for each file. It display the number of lines, number of words and number of bytes, respectively.
You can also explicitly specify what you want to display but using the l-, -w, or -c options which will displays number of lines, words, characters(bytes) respectively
let's try out to display the number of lines. Few free to also experiment with other options.
12. nl🐧
Another command you can use to check the count of lines on a file is the nl (number lines) command.
13. grep🐧
The grep command is one of the most common text processing command you will use. It allows you to search files for characters that match a certain pattern.
Grep has a lot of useful switches which I will not discussπŸ˜‡, but you can also check grep man pages if you want to know more about this handy utility.
14. diff🐧
The diff command simply compares two text sources/text files and outputs their differences.Β It compares the files line by line to find the differences.
15. Cut🐧
The cut command can be used to remove/extract bytes, characters, and fields from files. Various parameters are used to specify what part or parts of the file are to be removed or displayed.
Here is a quick example, let's say we want to display all the user shells in the /etc/passwd file.
That's it for today's thread! ThankπŸ’Œ you for readingπŸ“šIf you liked the thread and found it useful, give me a follow (@xtremepentest) for future Linux, Networking and Security content!. Be sure to also add some commands for text manipulation, would love to know them as well.πŸ˜‡

β€’ β€’ β€’

Missing some Tweet in this thread? You can try to force a refresh
γ€€

Keep Current with TRΓ„W🀟

TRΓ„W🀟 Profile picture

Stay in touch and get notified when new unrolls are available from this author!

Read all threads

This Thread may be Removed Anytime!

PDF

Twitter may remove this content at anytime! Save it as PDF for later use!

Try unrolling a thread yourself!

how to unroll video
  1. Follow @ThreadReaderApp to mention us!

  2. From a Twitter thread mention us with a keyword "unroll"
@threadreaderapp unroll

Practice here first or read more on our help page!

More from @thatstraw

Jul 11
Linux filesystem and directory structure🐧

πŸ“ /
β”œβ”€β”€ πŸ“ bin
β”‚ β”œβ”€β”€ βš™οΈ ls
β”‚ └── βš™οΈ bash
β”œβ”€β”€ πŸ“ boot
β”‚ β”œβ”€β”€ πŸ’Ύ vmlinuz
β”‚ └── πŸ’Ύ initrd.img
β”œβ”€β”€ πŸ“ dev
β”‚ β”œβ”€β”€ πŸ’Ώ sda1
β”‚ └── πŸ’Ώ sdb
β”œβ”€β”€ πŸ“ etc
β”‚ β”œβ”€β”€ πŸ› οΈ passwd
β”‚ └── πŸ› οΈ fstab
β”œβ”€β”€ πŸ“ home
β”‚ β”œβ”€β”€ πŸ“ james
β”‚ β”‚ β”œβ”€β”€ πŸ› οΈ .bashrc
β”‚ β”‚ β”œβ”€β”€ πŸ“ documents
β”‚ β”‚ └── πŸ“ .ssh
β”‚ β”‚ β”œβ”€β”€ πŸ” id_rsa
β”‚ β”‚ └── πŸ”‘ authorized_keys
β”‚ └── πŸ“ traw
β”‚ β”œβ”€β”€ πŸ› οΈ .profile
β”‚ β”œβ”€β”€ πŸ“ pictures
β”‚ └── πŸ“ .ssh
β”‚ β”œβ”€β”€ πŸ” id_rsa
β”‚ └── πŸ”‘ authorized_keys
β”œβ”€β”€ πŸ“ lib
β”‚ β”œβ”€β”€ βš™οΈ
β”‚ └── βš™οΈ
β”œβ”€β”€ πŸ“ media
β”‚ β”œβ”€β”€ πŸ“ cdrom
β”‚ └── πŸ“ usb
β”œβ”€β”€ πŸ“ mnt
β”‚ └── πŸ“ mymount
β”œβ”€β”€ πŸ“ opt
β”‚ └── πŸ“ myapp
β”œβ”€β”€ πŸ“ proc
β”‚ β”œβ”€β”€ πŸ“„ cpuinfo
β”‚ └── πŸ“„ meminfo
β”œβ”€β”€ πŸ“ root
β”‚ β”œβ”€β”€ πŸ› οΈ .bash_history
β”‚ └── πŸ“ .ssh
β”‚ β”œβ”€β”€ πŸ” id_rsa
β”‚ └── πŸ”‘ authorized_keys
β”œβ”€β”€ πŸ“ run
β”‚ β”œβ”€β”€ πŸ“„ utmp
β”‚ └── πŸ“„ systemd
β”œβ”€β”€ πŸ“ sbin
β”‚ β”œβ”€β”€ βš™οΈ init
β”‚ └── βš™οΈ reboot
β”œβ”€β”€ πŸ“ srv
β”‚ └── πŸ“ myservice
β”œβ”€β”€ πŸ“ sys
β”‚ β”œβ”€β”€ πŸ“„ devices
β”‚ └── πŸ“„ firmware
β”œβ”€β”€ πŸ“ tmp
β”‚ β”œβ”€β”€ πŸ“„ temp1
β”‚ └── πŸ“„ temp2
β”œβ”€β”€ πŸ“ usr
β”‚ β”œβ”€β”€ πŸ“ bin
β”‚ β”‚ β”œβ”€β”€ βš™οΈ perl
β”‚ β”‚ └── βš™οΈ python
β”‚ β”œβ”€β”€ πŸ“ lib
β”‚ β”‚ β”œβ”€β”€ βš™οΈ
β”‚ β”‚ └── βš™οΈ
β”‚ └── πŸ“ local
β”‚ β”œβ”€β”€ πŸ“ bin
β”‚ β”œβ”€β”€ πŸ“ lib
β”‚ └── πŸ“ share
└── πŸ“ var
β”œβ”€β”€ πŸ“ log
β”‚ β”œβ”€β”€ πŸ“„ syslog
└── πŸ“„ auth.log
β”œβ”€β”€ πŸ“ mail
β”œβ”€β”€ πŸ“ run
β”œβ”€β”€ πŸ“ spool
└── πŸ“ wwwlibc.so
libm.so
libssl.so
libcrypto.so
πŸ“ / (Root Directory)
β€’ The top-level directory of the filesystem. All other directories and files are contained within this directory.

πŸ“ /bin
β€’ Contains essential binary executables (commands like ls, bash). These are the basic commands needed for system operation.
πŸ“ /boot
β€’ Contains the boot loader files and kernel images (e.g., vmlinuz, initrd.img). These files are necessary to start the operating system.

πŸ“ /dev
β€’ Contains device files representing hardware devices (e.g., sda1, tty). These special files allow software to interact with hardware devices.
Read 10 tweets
Jul 9
REST API Design Image
Looking for a tool that simplifies API management? Introducing Apidog

Designing APIs can be complex, but tools like @ApidogHQ simplify the process. Apidog ( is a comprehensive API design-first development platform that offers numerous features to streamline API development. While many API design and management tools are available, Apidog stands out as a comprehensive solution.

You can check out and try Apidog using this link:
apidog.com/?utm_source=th…Image
Here's why Apidog is becoming the go-to platform for API design:

1. REAL API Design-first Development Platform

Apidog offers visual tools for API design, development, testing, and documentation. Its elegant UI and compatibility with OpenAPI Specification (OAS) eliminate the need for manual coding.

The platform also supports multi-branch API development, making it ideal for teams working on complex projects.Image
Read 8 tweets
Jun 4
If you want to learn Linux bash scripting for FREE, open this: Image
1. Getting Started with Bash Scripting

Bash scripts are a series of commands written in a file that can be executed by the Bash shell. This article will cover the basics of creating and running your first Bash script.
sysxplore.com/create-a-bash-…
2. Comments in Bash

Commenting your code is an essential practice in programming, as it helps you and others understand the purpose and functionality of each section.

In Bash scripting, comments are used to annotate your scripts, making them more readable and maintainable. This article will cover the different ways to add comments in your Bash scripts.
sysxplore.com/comments-in-ba…
Read 19 tweets
Dec 29, 2023
Linux hand-written notes:🧡 ↓ Image
[2] Image
[3] Image
Read 80 tweets
Oct 24, 2023
13 Linux tr command practical examples you should know as a system administrator: Image
The tr command short for translate, is one of the most useful command for manipulating text on the command line.
It allows you to perform useful operations such as converting lowercase characters to uppercase characters, uppercase characters to lowercase characters, character replacing, and deleting characters.

It is usually used in conjunction with other commands via piping.
Read 29 tweets
Jul 2, 2023
Linux user management - how to add users in Linux πŸ§΅β†“
The useradd command is the main tool for adding new users to a Linux system. This command allows you to quickly create a new user account and configure the user's $HOME directory structure.
The useradd command creates a user account by combining system default settings and command-line parameters.

To see the system default values on your Linux distribution, use the useradd command with the -D option:

$ useradd -D
Read 18 tweets

Did Thread Reader help you today?

Support us! We are indie developers!


This site is made by just two indie developers on a laptop doing marketing, support and development! Read more about the story.

Become a Premium Member ($3/month or $30/year) and get exclusive features!

Become Premium

Don't want to be a Premium member but still want to support us?

Make a small donation by buying us coffee ($5) or help with server cost ($10)

Donate via Paypal

Or Donate anonymously using crypto!

Ethereum

0xfe58350B80634f60Fa6Dc149a72b4DFbc17D341E copy

Bitcoin

3ATGMxNzCUFzxpMCHL5sWSt4DVtS8UqXpi copy

Thank you for your support!

Follow Us!

:(