Linux Commands part - 2
$file images.png
output-
Dimensions file type 8 bit color map
$less file.txt
this command shows overwhelm text in one screen at a time.
$sudo apt install imagemagick
$identify images.png
Gives the properties of the images etc...
$mkdir -p /home/Desktop/maverick/Documents/MyDocuments/
This command gonna create sub-directory.
$ mkdir -p Soumya/Documents/Kali.pdf/ | touch mk.txt
Find
$$ find /home -name puppies.jpg
$$ find /home -type d -name MyFolder
18. alias
Sometimes typing commands can get really repetitive, or if you need to type a long command many times, it’s best to have an alias you can use for that. To create an alias for a command you simply specify an alias name and set it to the command.
$ alias foobar='ls -la'
Now instead of typing ls -la, you can type foobar and it will execute that command, pretty neat stuff. Keep in mind that this command won't save your alias after reboot, so you'll need to add a permanent alias in:
~/.bashrc
or similar files if you want to have it persist after reboot.
You can remove aliases with the unalias command:
$ unalias foobar
$ pwd < Data.txt > Data1.txt
Data1.txt contains current working directory path text.
$ ls -la /etc
$ ls -la /etc | less
$ ls | tee peanuts.txt
Delhi is the place of dilwale
Above commands gives the output after the delimeter (.).
$ expand sample.txt > result.txt
And also sort via numerical value:
$ sort -n file1.txt
bird
cat
cow
elephant
dog
Examples:
Translate all uppercase characters to lowercase:
bashecho "HELLO" | tr '[:upper:]' '[:lower:]'
Delete all digits from input:
bashecho "Hello123" | tr -d '[:digit:]'
Replace spaces with tabs:
bashecho "Hello World" | tr ' ' '\t'
Remove all non-alphanumeric characters:
bashecho "Hello, world!" | tr -cd '[:alnum:]'
- echo "maverick" | tr a-z A-Z
- echo a-z A-Z
- maverick
- Maverick
uniq (Unique)
he uniq (unique) command is another useful tool for parsing text.
Let's say you had a file with lots of duplicates:
reading.txt
book
book
paper
paper
article
article
magazine
$ uniq reading.txt
book
paper
article
magazine
2. System V Service
All service commands
There are many command line tools you can use to manage Sys V services.
List services
$ service --status-all
Start a service
$ sudo service networking start
Stop a service
$ sudo service networking stop
Restart a service
$ sudo service networking restart
Comments
Post a Comment