Posts

Showing posts with the label Bash

Find Files in the terminal with Bash

Image
  There are 3 commands in Linux to find files. whereis which find whereis returns binaries, source files, and manual pages. get the location of the bash executable file and the manual (man) file only get the location of the bash file which only returns executables or source files get the location of the bash executable file find returns all the search results from a particular hierarchy to get all the files with .md extension in the current working directory. to get the file with the name file,txt in a different directory (in this case home directory) in the below command only gives the exact file with name file.txt , if case sensitivity can be removed it will return all the files that have same name. to get all the files with the type directory

List Content in the Terminal with Bash

Image
ls - lists the files in the directory Use of wildcards to find every file starts with capital s to find every file starts with capital c and capital s to find file/files with the .md extension to find file/files with any two-character extension (the number of  "?" represents the character length of the extension) to find file/files start with and upper case characters  to find file/files start with and lower case characters 

Navigate the Terminal with Bash

Image
pwd - print working directory tree - shows the directory structure whoami - whom as I'm logged in cd  - change directory cd ~  - goes home directory  I'm using a directory structure created like the one below. cd ..   or cd ../ - goes one level back cd ../..   or cd ../../ - goes two levels back pushd and popd pushd saves the current directory and changes to a new one, while popd reverts to the previously saved directory. They allow easy navigation between directories in a stack-like manner. Credits The article “How to Get Help in Bash” draws inspiration from and references the following YouTube video: Video Title: “How to Navigate the Terminal with Bash [5 of 20] | Bash for Beginners” YouTube Link:  Watch Here Original Video Creators: Josh Duffney Gwyneth Peña-Siguenza I would like to express my gratitude to Josh Duffney and Gwyneth Peña-Siguenza for creating the informative and helpful video that served as a valuable resource in the development of this...

How to get help in Bash

Image
There are two commands for you to get help in the Bash. They are help and the man command. But you need to know the command you want to use in order to get help on it. help Let’s say you want to help with cd command. So in your Bash shell type help cd Now what you need to focus on is the first line. in this case, it is so this is the command itself and all the optional parameters it has in order to use it. So anything inside the square bracket is optional, and anything that is divided by a vertical bar, or usually we call by pipe symbol “|” meaning it’s mutually exclusive, which means you can use only one of the options but not both. For example, you can use cd -L -e /path/to/directory cd -P -e /path/to/directory but not L -P -e /path/to/directory Now you u have thought of what does this -L, -P really means. So those are listed in the options section. So to make the most use of this command you need to scan the top section of the command and then the options section. both I described...

Getting Started with Bash: A Beginner's Guide to Linux Command Line

Image
Hi So if you are new to Linux or planning to get your self dirty with Linux this post is for you.  Now a little bit of history lesson and some things to keep in your mind. Bash is not the one and only CLI language used in Linux, but it is the most popular one . Why it is so popular, well it is the default shell for majority of Linux distributions like Ubuntu, Debian, CentOS, Fedora and many more. Also Bash is highly compatible with other Unix-like systems  which means that scripts written in Bash can often be easily ported to other platforms , such as macOS or BSD. in addition to to this it's rich feature set including variables, loops, functions and whole lot more allows complex command line operations . Because of that it is used as the primary language for System Administration tasks. Finally  and most importantly Bash has a huge community built around it and a whole lot of resources including tutorials, forums for you to learn and solve problems. Let's start. Cho...