- Red Hat / CentOS Check and List Running Services Linux Command
- Red Hat / CentOS Check and List Running Services Command
- List running services using service command on a CentOS/RHEL 6.x or older
- Print the status of any service
- List all known services (configured via SysV)
- List service and their open ports
- Turn on / off service
- Red Hat / CentOS List Running Services using systemctl ( RHEL/CentOS 7.x/8.x )
- To list systemd services on CentOS/RHEL 7.x+ use
- Linux / Unix Find All The Files Owned By a Particular User / Group
- Linux / Unix Find All The Files Owned By a Particular User / Group
- Find file owned by a group
- Find all *.mp4 files by group vivek
- Find file owned by user
- How to find files by users vivek and wendy
- How to Manage and List Services in Linux
- Linux Services
- How to List Services in Linux
- Managing Linux Services
- Conclusion
- How to List Services in Linux
- Check and Listing linux services (systemd on Centos/RHEL 7.x)
- Listing services using Netstat Command
- Viewing /etc/services file
- Systemd services status check
- Checking the status of services in older systems (Centos/Rhel 6.x)
- Команда find в Linux
- Основная информация о Find
- Основные параметры команды find
- Критерии
- Примеры использования
- 1. Поиск всех файлов
- 2. Поиск файлов в определенной папке
- 3. Ограничение глубины поиска
- 4. Инвертирование шаблона
- 5. Несколько критериев
- 6. Несколько каталогов
- 7. Поиск скрытых файлов
- 8. Поиск по разрешениям
- 9. Поиск файлов в группах и пользователях
- 10. Поиск по дате модификации
- 11. Поиск файлов по размеру
- 12. Поиск пустых файлов и папок
- 13. Действия с найденными файлами
- Выводы
Red Hat / CentOS Check and List Running Services Linux Command
H ow do I list all currently running services in Fedora / RHEL / CentOS Linux server? How can I check the status of a service using systemd based CentOS/RHEL 7.x and RHEL/CentOS 8.x?
There are various ways and tools to find and list all running services under a Fedora / RHEL / CentOS Linux systems.
Tutorial details | |
---|---|
Difficulty level | Easy |
Root privileges | Yes |
Requirements | RHEL or CentOS Linux |
Est. reading time | 6 minutes |
Red Hat / CentOS Check and List Running Services Command
Please note that systemd based system such as CentOS/RHEL 7.x/8.x and latest version of fedora use the systemctl command to list running services
List running services using service command on a CentOS/RHEL 6.x or older
The syntax is as follows for CentOS/RHEL 6.x and older (pre systemd systems) :
service —status-all
service —status-all | more
service —status-all | grep ntpd
service —status-all | less
Print the status of any service
To print the status of apache (httpd) service:
service httpd status
Display status of sshd service:
service sshd status
List all known services (configured via SysV)
List service and their open ports
Turn on / off service
ntsysv
chkconfig service off
chkconfig service on
chkconfig httpd off
chkconfig ntpd on
ntsysv is a simple interface for configuring runlevel services which are also configurable through chkconfig. By default, it configures the current runlevel. Just type ntsysv and select service you want to run.
Red Hat / CentOS List Running Services using systemctl ( RHEL/CentOS 7.x/8.x )
If you are using systemd based Linux distros such as Fedora Linux v22/23/24/26/27/28/29/30/31 or RHEL/CentOS Linux 7.x/8.x. Try the following command to list running services using the systemctl command. It control the systemd system and service manager.
To list systemd services on CentOS/RHEL 7.x+ use
The syntax is:
systemctl
systemctl | more
systemctl | grep httpd
systemctl list-units —type service
systemctl list-units —type mount
To list all services:
systemctl list-unit-files
Sample outputs:
Fig.01: List all units installed on the CentOS /RHEL 7 systemd based system, along with their current states
Источник
Linux / Unix Find All The Files Owned By a Particular User / Group
Linux / Unix Find All The Files Owned By a Particular User / Group
Let us see how to use the find command to locate all files/folders owned by one or many users on Linux or Unix-like system.
Find file owned by a group
Tutorial details | |
---|---|
Difficulty level | Easy |
Root privileges | Yes |
Requirements | Linux or Unix |
Est. reading time | 2m |
Use the following syntax to find files owned by users(s) in Linux/Unix:
find directory-location -group < group-name >-name < file-name >
Where,
- directory-location : Locate the file in this directory path.
- -group
: Find the file belongs to group-name. - -name
: The file name or a search pattern
In this example, locate or find all files belongs to a group called “ftpusers” in the /home directory:
# find /home -group ftpusers
To find all *.c file belongs to a group called “ftpusers” in /data/project directory, run:
# find /data/project -group ftpusers -name «*.c»
OR do case insensitive search:
# find /data/project -group ftpusers -iname «*.c»
Find all *.mp4 files by group vivek
Find file owned by user
The syntax is:
find directory-location -user < username >-name < file-name >
Where,
- directory-location : Locate files or directories in this directory location.
- -user < user-name >: Find the file belongs to user.
- -name
: File name or pattern.
In this example, locate or find all file belongs to a user called “vivek” in /var directory:
# find /var -user vivek
To find all *.pl (perl files) file belongs to a user called “vivek” in /var/www directory, enter:
# find /var/www -user vivek -name «*.pl»
- No ads and tracking
- In-depth guides for developers and sysadmins at Opensourceflare✨
- Join my Patreon to support independent content creators and start reading latest guides:
- How to set up Redis sentinel cluster on Ubuntu or Debian Linux
- How To Set Up SSH Keys With YubiKey as two-factor authentication (U2F/FIDO2)
- How to set up Mariadb Galera cluster on Ubuntu or Debian Linux
- A podman tutorial for beginners – part I (run Linux containers without Docker and in daemonless mode)
- How to protect Linux against rogue USB devices using USBGuard
Join Patreon ➔
How to find files by users vivek and wendy
### match files only ##
# find / -type f -user vivek -o -user wendy
### match dirs only ##
# find / -type d -user vivek -o -user wendy
Conclusion
You just learned how to find all of the files created by a particular user/group and display them to the screen. For more info see find command man page.
🐧 Get the latest tutorials on Linux, Open Source & DevOps via
Источник
How to Manage and List Services in Linux
Managing a Linux VPS is a critical and sometimes very difficult task if you don’t have the right tools. Often the difficulty lies in having to configure and maintain many resources and services. On a server, most resources are software making them a little easier to monitor. In this tutorial, you’ll learn all the Linux service basics, including how to manage, control, and list services in Linux.
Linux Services
A service is a program that runs in the background outside the interactive control of system users as they lack an interface. This in order to provide even more security, because some of these services are crucial for the operation of the operating system.
On the other hand, in systems like Unix or Linux, the services are also known as daemons. Sometimes the name of these services or daemons ends with the letter d. For example, sshd is the name of the service that handles SSH.
So, let us start to work and list services in Linux.
How to List Services in Linux
Let’s look at a potential scenario. While running your Linux system, you can no longer access localhost. Chances are that the HTTP service was disabled, and causing the problem.
To troubleshoot issues like this one and many others, it’s good to know how to list all services in Linux.
Fortunately, CentOS and Ubuntu – two of the most popular operating systems in their areas – share systemd. That means that the commands we are going to present are compatible with both systems.
First, we have to connect to our server using SSH. If you’re having trouble, check out our PuTTY tutorial.
Once inside, we need to be the root user to list service in Linux.
Now we can list all services in Linux. To do it, run the command:
When the command is run, we will see all the services that are on the system. However, we will also see that some have a defined status. Let’s learn what all these mean.
- Enabled services are currently running. They usually have no problems.
- Disabled services are not active but can be activated at any time without a problem.
- Masked services won’t run unless we take that property away from them.
- Static services will only be used in case another service or unit needs it.
- Finally, there are services generated through a SysV or LSB initscript with systemd generator.
In case we want to know only the services that are active, we have to use a command together with grep, like so:
Managing Linux Services
Now it is time to learn how to manage a specific service. Note that each service represents software that works differently. In this tutorial, we will only show how to start, check the status of and stop services – the basic controls
To start a service on Linux, we need to run the following command:
If the service is correctly configured, it will start. Now, if we want to stop it, we will use the following command:
Meanwhile, to check the status of a service we can use:
It is also possible to have a service run while the operating system is being loaded:
Or remove it from the initial load:
Finally, it is possible to verify which port is being used by a service. For this, we will use netstat.
To install it on Ubuntu, we just run:
If we are using CentOS 7:
Then, we run the following command:
The output will give us all the required network information.
Conclusion
Learning how to list services in Linux is easy and can greatly speed up troubleshooting! In this tutorial, we learned how to start, enable, disable, stop, and list all services in Linux! Now you can manage your Linux VPS like a pro.
Finally, we recommend you to read more about systemctl to learn all the in-depth uses. Happy developing!
Edward is an expert communicator with years of experience in IT as a writer, marketer, and Linux enthusiast. IT is a core pillar of his life, personal and professional. Edward’s goal is to encourage millions to achieve an impactful online presence. He also really loves dogs, guitars, and everything related to space.
Источник
How to List Services in Linux
In this article, I will show you how to list all running services on Linux. We will also check how to check the status of a service on a systemd system.
Let’s learn different commands used to list services on Centos/RHEL 7.x.
Check and Listing linux services (systemd on Centos/RHEL 7.x)
To list systemd services we will use systemctl command as below
Sample Output
To list active systemd services run
Sample Output
Another command you can use is
Sample Output
You can pipe the output to grep to search a more specific service as shown below
Output
Listing services using Netstat Command
Nestat command is a tool used for examining active network connections, interface statistics as well as the routing table. It’s available in all Linux distributions and here we will check how to list services using netstat command.
To check the services alongside the ports they are listening.
Output
Viewing /etc/services file
The /etc/services is an ASCII file that contains information about numerous services that client applications might use on the computer. Within the file is the service name, port number and protocol it uses, and any applicable aliases. ITO put t indicates whether a service is TCP or UDP and the name it goes by according to IANA. This information is helpful especially if you are unsure which service is running on which port by default.
To get a clearer picture, view the /etc/services file using a text editor of your choice.
Output
Systemd services status check
In newer versions of Linux, Systemd init is present. To check if a service is running, use the syntax below
Syntax
For example, to check if OpenSSH is running on your system, run
Output
Alternatively, you can use the syntax below to check if the service is active
In this case, to check if OpenSSH is active, execute
Output
Also, you can use the command below to check if a service is enabled
To check if OpenSSH is enabled, run
Output
Checking the status of services in older systems (Centos/Rhel 6.x)
For systems running SysV Init, you can check the status of services by running
For example, to check the status of OpenSSH, run
Output
You can also check all services by running
Output
We hope you found this article useful. Feel free to try out some of the systemd commands listed here.
Источник
Команда find в Linux
Очень важно уметь вовремя и очень быстро найти нужную информацию в системе. Конечно, все современные файловые менеджеры предлагают отличные функции поиска, но им не сравнится с поиском в терминале Linux. Он намного эффективнее и гибче обычного поиска, вы можете искать файлы не только по имени, но и по дате добавления, содержимому, а также использовать для поиска регулярные выражения. Кроме того, с найденными файлами можно сразу же выполнять необходимые действия.
В этой статье мы поговорим о поиске с помощью очень мощной команды find Linux, подробно разберем ее синтаксис, опции и рассмотрим несколько примеров.
Основная информация о Find
Find — это одна из наиболее важных и часто используемых утилит системы Linux. Это команда для поиска файлов и каталогов на основе специальных условий. Ее можно использовать в различных обстоятельствах, например, для поиска файлов по разрешениям, владельцам, группам, типу, размеру и другим подобным критериям.
Утилита find предустановлена по умолчанию во всех Linux дистрибутивах, поэтому вам не нужно будет устанавливать никаких дополнительных пакетов. Это очень важная находка для тех, кто хочет использовать командную строку наиболее эффективно.
Команда find имеет такой синтаксис:
find [ папка] [ параметры] критерий шаблон [действие]
Папка — каталог в котором будем искать
Параметры — дополнительные параметры, например, глубина поиска, и т д
Критерий — по какому критерию будем искать: имя, дата создания, права, владелец и т д.
Шаблон — непосредственно значение по которому будем отбирать файлы.
Основные параметры команды find
Я не буду перечислять здесь все параметры, рассмотрим только самые полезные.
- -P никогда не открывать символические ссылки
- -L — получает информацию о файлах по символическим ссылкам. Важно для дальнейшей обработки, чтобы обрабатывалась не ссылка, а сам файл.
- -maxdepth — максимальная глубина поиска по подкаталогам, для поиска только в текущем каталоге установите 1.
- -depth — искать сначала в текущем каталоге, а потом в подкаталогах
- -mount искать файлы только в этой файловой системе.
- -version — показать версию утилиты find
- -print — выводить полные имена файлов
- -type f — искать только файлы
- -type d — поиск папки в Linux
Критерии
Критериев у команды find в Linux очень много, и мы опять же рассмотрим только основные.
- -name — поиск файлов по имени
- -perm — поиск файлов в Linux по режиму доступа
- -user — поиск файлов по владельцу
- -group — поиск по группе
- -mtime — поиск по времени модификации файла
- -atime — поиск файлов по дате последнего чтения
- -nogroup — поиск файлов, не принадлежащих ни одной группе
- -nouser — поиск файлов без владельцев
- -newer — найти файлы новее чем указанный
- -size — поиск файлов в Linux по их размеру
Примеры использования
А теперь давайте рассмотрим примеры find, чтобы вы лучше поняли, как использовать эту утилиту.
1. Поиск всех файлов
Показать все файлы в текущей директории:
2. Поиск файлов в определенной папке
Показать все файлы в указанной директории:
Искать файлы по имени в текущей папке:
Не учитывать регистр при поиске по имени:
find . -iname «test*»
3. Ограничение глубины поиска
Поиска файлов по имени в Linux только в этой папке:
find . -maxdepth 1 -name «*.php»
4. Инвертирование шаблона
Найти файлы, которые не соответствуют шаблону:
find . -not -name «test*»
5. Несколько критериев
Поиск командой find в Linux по нескольким критериям, с оператором исключения:
find . -name «test» -not -name «*.php»
Найдет все файлы, начинающиеся на test, но без расширения php. А теперь рассмотрим оператор ИЛИ:
find -name «*.html» -o -name «*.php»
6. Несколько каталогов
Искать в двух каталогах одновременно:
find ./test ./test2 -type f -name «*.c»
7. Поиск скрытых файлов
Найти скрытые файлы:
8. Поиск по разрешениям
Найти файлы с определенной маской прав, например, 0664:
find . type f -perm 0664
Найти файлы с установленным флагом suid/guid:
find / -perm 2644
find / -maxdepth 2 -perm /u=s
Поиск файлов только для чтения:
find /etc -maxdepth 1 -perm /u=r
Найти только исполняемые файлы:
find /bin -maxdepth 2 -perm /a=x
9. Поиск файлов в группах и пользователях
Найти все файлы, принадлежащие пользователю:
find . -user sergiy
Поиск файлов в Linux принадлежащих группе:
find /var/www -group developer
10. Поиск по дате модификации
Поиск файлов по дате в Linux осуществляется с помощью параметра mtime. Найти все файлы модифицированные 50 дней назад:
Поиск файлов в Linux открытых N дней назад:
Найти все файлы, модифицированные между 50 и 100 дней назад:
find / -mtime +50 –mtime -100
Найти файлы измененные в течении часа:
11. Поиск файлов по размеру
Найти все файлы размером 50 мегабайт:
От пятидесяти до ста мегабайт:
find / -size +50M -size -100M
Найти самые маленькие файлы:
find . -type f -exec ls -s <> \; | sort -n -r | head -5
find . -type f -exec ls -s <> \; | sort -n | head -5
12. Поиск пустых файлов и папок
find /tmp -type f -empty
13. Действия с найденными файлами
Для выполнения произвольных команд для найденных файлов используется опция -exec. Например, выполнить ls для получения подробной информации о каждом файле:
find . -exec ls -ld <> \;
Удалить все текстовые файлы в tmp
find /tmp -type f -name «*.txt» -exec rm -f <> \;
Удалить все файлы больше 100 мегабайт:
find /home/bob/dir -type f -name *.log -size +100M -exec rm -f <> \;
Выводы
Вот и подошла к концу эта небольшая статья, в которой была рассмотрена команда find. Как видите, это одна из наиболее важных команд терминала Linux, позволяющая очень легко получить список нужных файлов. Ее желательно знать всем системным администраторам. Если вам нужно искать именно по содержимому файлов, то лучше использовать команду grep.
Источник