How to find your way from the Linux team as professionals



How do we find the Linux command path that we just installed on Linux using a management pack like the apt / dnf command? Today, many developers work with the Linux operating system. Meanwhile, some of them use Linux from WSL, while others deal directly with cloud servers via SSH. In this article, we will introduce you to some common commands for indexing or finding a path from the Linux command; So join us.

What is the Linux command?

In Windows, the default user interface is the graphical user interface; However, Linux is configured by the server in the default text interface. Therefore, they often use terms such as Bash, Shell, Console, Command Prompt Terminal and many other names. All these phrases refer to a text interface. For example, in MS Windows, click Start to launch applications.

In the same way, you enter instructions in the terminal, known as the Linux command. For example, you can press Ctrl + Alt + T to start the Linux terminal. Then enter a simple command such as date to see today’s date and time. To run the Date command, type all the letters in italics, and then press Enter.

Linux terminal commands

General commands on the Linux terminal

Different types of Linux commands

There are different types of Linux commands that are entered into the terminal. Here are some of them:

  • Internal or built-in shell command
  • External / executable / file command
  • Shell function
  • Alias
  • Keyword

How to recognize the Linux command type?

To show the path of the Linux command, you must use the Type command. This command indicates whether the command is embedded in a shell, alias, function, or external. Its syntax is as follows:

type command
type -t command
type -a command

For example, consider the pwd command:

type pwd
type date
type hello
type ping

# Display a single word which is one of 'alias', 'keyword', 'function', 'builtin',
# 'file or '' , if command is an alias, shell reserved word, shell function, shell builtin,
# disk file, or not found, respectively
type -t ping
type -t if
type -t vi
type -t nano

# The '-a' option shows all locations containing an executable named ping
type -a ping

Detect a command for a Linux terminal

Detect command types in Linux Command

What is the $ PATH variable?

The PATH variable consists of a set of directories that store executable programs such as ping, date, vi, and docker on Linux or similar Unix systems. To see your current path, use the echo / printf command:

echo "$PATH"

# OR
#
# More human readable format
#
echo "${PATH//:/$'n'}"

Finally you will see the path:

/home/vivek/google-cloud-sdk/bin
/home/vivek/.local/bin
/home/vivek/bin
/usr/local/sbin
/usr/local/bin
/usr/sbin
/usr/bin
/sbin
/bin
/usr/games
/usr/local/games
/snap/bin

To see all executable programs stored in the / bin / directory, run the ls command as follows:

ls /bin/
ls -l /bin/

How to display Command information

To set the Linux command path, use the Command command:

command -v date
command -v pwd
command -v ping
command -v docker

How to find a command in Linux

Which command can you use to easily find the Linux command path? for example:

which gcc
which nano

To print all matching paths, use a-:

which -a ls

Find the Linux command path

Learn how to find the Linux command path

Take the path from the Linux command or the Man page

Use the Whereis command to find the binary page and source code and the Man page for a specific program or command on disk. For example:

whereis command
whereis gcc
whereis docker
whereis lxc
whereis vim

If you only want to display binaries, use the following code:

whereis -b ls

If you only want to search for manual and information pages, use the following code:

whereis -m date
whereis -m gcc

Find the path in the Linux command

Steps to get a path from a Linux command

Find and Find commands

You can also find files by their name. For example, we want to look for a file called “date”:

locate -b 'date'
## OR ##
find / -name "date" -ls
# sudo for all files
sudo find / -name "date" -ls

Exit commands find:

/snap/core/11316/bin/date
/snap/core/11420/bin/date
/snap/core18/2066/bin/date
/snap/core18/2074/bin/date
/snap/core20/1026/usr/bin/date
/snap/core20/1081/usr/bin/date
/usr/bin/date
/usr/lib/byobu/date

Show help for Linux commands

Use the Whatis, Help and Man commands or Information commands.

About the Whatis command

Each Linux command comes with a manual page. There is also a brief explanation. For example, the Whatis command looks for the name of the Guide page. In fact, the description of the Guide page indicates the name that will be linked to it in a short form:

whatis ls
whatis clear
whatis date
whatis gcc

What is a command in Linux

The team What’s in the Linux terminal

Use the Man command or the Info command for all external commands to get a detailed guide:

man date
man ls
man gcc
man bash
info ls
info bash
man which

Sample man pages in Linux

Introduction to the man pages in Linux

The help command is used for all keywords and built-in Bash:

help if
help exit
help logout
help type
help command

Conclusion

Getting the command location is a problem for novice programmers; But with the help of this simple page you can find command paths and even get information about them using the Man page. Suppose you have Docker installed on your Ubuntu server; Therefore, you can use the following commands to find a path and help:

whatis docker
whereis docker
type -a docker
which docker
find / -iname "docker"
locate -b 'docker'
man docker

For a Debian or Ubuntu Linux server, try the following two commands. Use the dpkg command to list all the files installed on the server using the Docker package:

dpkg -L docker-ce
dpkg -L docker-ce | more
/.
/etc
/etc/default
/etc/default/docker
/etc/init
/etc/init/docker.conf
/etc/init.d
/etc/init.d/docker
/lib
/lib/systemd
/lib/systemd/system
/lib/systemd/system/docker.service
/lib/systemd/system/docker.socket
/usr
/usr/bin
/usr/bin/docker-init
/usr/bin/docker-proxy
/usr/bin/dockerd
/usr/share
/usr/share/doc
/usr/share/doc/docker-ce
/usr/share/doc/docker-ce/README.md
/usr/share/doc/docker-ce/changelog.Debian.gz

Also use the APT command to display information about the Docker package:

apt show docker-ce
Package: docker-ce
Version: 5:19.03.13~3-0~ubuntu-bionic
Priority: optional
Section: admin
Maintainer: Docker <[email protected]>
Installed-Size: 107 MB
Depends: docker-ce-cli, containerd.io (>= 1.2.2-3), iptables, libseccomp2 (>= 2.3.0), libc6 (>= 2.8), libdevmapper1.02.1 (>= 2:1.02.97), libsystemd0
Recommends: aufs-tools, ca-certificates, cgroupfs-mount | cgroup-lite, git, pigz, xz-utils, libltdl7, apparmor
Conflicts: docker (<< 1.5~), docker-engine, docker-engine-cs, docker.io, lxc-docker, lxc-docker-virtual-package
Replaces: docker-engine
Homepage: https://www.docker.com
Download-Size: 22.5 MB
apt-manual-installed: yes
apt-sources: https://download.docker.com/linux/ubuntu bionic/edge amd64 Packages
Description: Docker: the open-source application container engine
Docker is a product for you to build, ship and run any application as a
lightweight container
.
Docker containers are both hardware-agnostic and platform-agnostic. This means
they can run anywhere, from your laptop to the largest cloud compute instance and
everything in between - and they don't require you to use a particular
language, framework or packaging system. That makes them great building blocks
for deploying and scaling web apps, databases, and backend services without
depending on a particular stack or provider.

N: There are 29 additional records. Please use the '-a' switch to see them.

This article can be useful for new Linux users and developers. Then mark it so you have quick access to it when needed.

Frequently Asked Questions

1 How to use Linux commands?

The Linux terminal is a user-friendly terminal; Because it offers different support options. To open the Linux terminal, press the “CTRL + ALT + T” keys together and execute a command by pressing the “Enter” key.

2. How many commands does Linux have?

The Linux kernel and other Unix-like operating systems share more than 100 Unix commands.

3. How do I get the file path in Windows?

First click the Start button and then Computer to open the location of the desired file. Then hold down the Shift key and right-click on the file. Then click Copy as Path to paste the full path of the file into the document. Now click Properties to see the file path (location) immediately.

{“@context”: “https://schema.org”, “@type”: “FAQPage”, “mainEntity”: [{
“@type”: “Question”,
“name”: “چگونه از دستورهای لینوکس استفاده کنیم؟”,
“acceptedAnswer”: {
“@type”: “Answer”,
“text”: “ترمینال لینوکس ترمینالی کاربر‌‌پسند است؛ زیرا گزینه‌های پشتیبانی مختلفی ارائه می‌دهد. برای باز‌کردن ترمینال لینوکس، کلیدهای «CTRL + ALT + T» را با‌هم فشار دهید و یک فرمان را با فشار‌دادن کلید «Enter» اجرا کنید.”
}
},{
“@type”: “Question”,
“name”: “لینوکس چند دستور دارد؟”,
“acceptedAnswer”: {
“@type”: “Answer”,
“text”: “هسته لینوکس و سایر سیستم‌عامل‌های مشابه یونیکس بیش از ۱۰۰ دستور یونیکس را به‌اشتراک گذاشته‌اند.”
}
},{
“@type”: “Question”,
“name”: “چگونه مسیر یک فایل را در ویندوز به‌دست بیاوریم؟”,
“acceptedAnswer”: {
“@type”: “Answer”,
“text”: “ابتدا روی دکمه Start و سپس Computer کلیک کنید تا محل فایل مدنظرتان باز شود. درادامه، کلید Shift را نگه دارید و روی فایل کلیک‌راست کنید. پس‌ازآن، روی گزینه Copy As Path کلیک کنید تا مسیر فایل کامل در داکیومنت جای‌گذاری شود. حالا روی Properties کلیک کنید تا بلافاصله بتوانید مسیر فایل (موقعیت) را مشاهده کنید.”
}
}]
}

Write how to find your way from the Linux team as professionals for the first time in Parsupak. appear.

Leave Your Comment

Your email address will not be published.

Supportscreen tag