Linux command
hostctl 命令
文本
复制后可按需替换文件名、目录或参数。
常用示例
List all profiles
hostctl list
Add entries to a profile
hostctl add [profile_name] [ip] [hostname]
Enable a profile
hostctl enable [profile_name]
Disable a profile
hostctl disable [profile_name]
Remove a profile
hostctl remove [profile_name]
Import a profile from a file
hostctl set [profile_name] -from [path/to/file]
Create a backup
hostctl backup
Sync profile with Docker Compose
hostctl sync dockercompose -f [docker-compose.yml] -p [profile_name]
说明
hostctl is a CLI tool for managing your /etc/hosts file using profiles. You can have multiple profiles, enable or disable exactly what you need, and switch between different host configurations with simple commands. It automatically detects your OS and uses the correct hosts file location. Profiles allow grouping host entries for different environments (development, staging, production) and toggling them on or off without manual file editing. It also supports syncing profiles with Docker and Docker Compose containers.
参数
- list
- Show a detailed list of profiles and entries
- add _profile_ _ip_ _hostname_
- Add an entry to a profile
- enable _profile_
- Enable a profile
- disable _profile_
- Disable a profile
- remove _profile_
- Remove a profile entirely
- set _profile_
- Replace content of a profile
- backup
- Create a backup of the hosts file
- sync
- Sync with Docker or Docker Compose
FAQ
What is the hostctl command used for?
hostctl is a CLI tool for managing your /etc/hosts file using profiles. You can have multiple profiles, enable or disable exactly what you need, and switch between different host configurations with simple commands. It automatically detects your OS and uses the correct hosts file location. Profiles allow grouping host entries for different environments (development, staging, production) and toggling them on or off without manual file editing. It also supports syncing profiles with Docker and Docker Compose containers.
How do I run a basic hostctl example?
Run `hostctl list` in a terminal, then adjust file names, paths, flags, or remote targets for your system.
What does list do in hostctl?
Show a detailed list of profiles and entries