Red Hat Enterprise Linux and Red Hat OpenShift provide users and admins with a friendly graphical UI for easier cloud management. But even with a clear UI, if you're running applications in the cloud, there's a good chance Red Hat OpenShift Service on AWS (ROSA) users can benefit from knowing some essential Linux commands.
Running a command in a terminal is fast and direct. It lets you communicate exactly what you want to happen, in one succinct sentence. There are hundreds of commands on a typical Linux system though, so here are 10 of the most important commands ROSA users need to know.
1. rosa
The rosa
command is your entry into your ROSA cluster. Of course, you can go to the AWS site to manage your ROSA cluster, but the important thing is that you don't have to. For some tasks, it's faster to just run a rosa
command. Here are some of the really useful ones:
Create a new cluster called mycluster
:
$ rosa create cluster --cluster-name=mycluster
Create an administrator for the new cluster:
$ rosa create admin --cluster=mycluster
And then get a list of users:
rosa list users --cluster=mycluster
2. oc
While the rosa
command provides you direct access to the cloud running your cluster, the oc
command gives you direct access to OpenShift. It's the difference between accessing a computer and the computer's operating system: one lets you configure the components of the platform, and the other lets you install and run software.
With oc
, you can do anything you'd normally do in OpenShift in your web browser. You can create a new project, start up an app, configure storage volumes and open a service to your users. There are lots of ways to create new applications, including Source-to-Image (S2I), OpenShift templates, container images and custom code.
For instance, with oc
, you can install a complex web server like Apache HTTP Server just by using a template included with OpenShift:
$ oc new-app --template=openshift/httpd-example
The version of oc
must match the version of OpenShift you're using, so download it from within your OpenShift instance.
3. curl
When you work with ROSA, you can expect to be working across networks more often than not. That's the nature (and power) of cloud computing. The curl
command is a non-interactive web browser for the terminal, meaning you can use it to visit a web address without opening a web browser like Chrome or Firefox. While you could use it to view content online, it's usually used to quickly grab a resource that doesn't require any interaction, like an install script, a YAML configuration you need to apply to your cloud environment, or a software package.
The syntax is simple. You type the command followed by the URL you want it to visit, followed by the --remote-name option to save the remote resource to your drive:
$ curl http://example.com --remote-name
That command downloads an example index page from the Internet, and saves it to your drive as index.html.
Another common use for curl
is as a test tool for an API. The oc
command uses the OpenShift API so you can perform maintenance and development tasks remotely, so curl
is a natural companion.
Sometimes an API responds to just a ping. When you visit the URL, the API is triggered. In that case, you just point curl
to the API endpoint, and omit the --remote-name
option because you don't need to download and save anything. You just want to trigger the endpoint:
$ curl http://nginx-example-myproject.apps-crc.testing/
Sometimes, an API is designed to respond to only specific types of HTTP requests. You can specify how you send test data with the --request
option:
$ curl --request POST \ --data "user:developer" \ --data "auth:$MY_TOKEN" \ "https://example.com/api/endpoint"
You can use as many --data
options as you need to pass the data you know the API requires (or to send more than it requires to test how it handles unexpected input).
The curl
command is installed by default on Red Hat Enterprise Linux and other distributions, and even macOS.
4. unzip
Archives online are often bundled as a ZIP file. You're going to need to extract data from a ZIP archive. The unzip
command can unpack a ZIP file:
$ unzip crc-linux-X.YY.0-amd64.zip
Pro tip: You can avoid typing out long archive names. Press the Tab key after typing just the first few letters of the archive to prompt your terminal to complete the name for you.
5. tar
Another common archive format you're likely to encounter is the TAR format, usually encapsulated by one of many compression algorithms (tar.gz and tar.xz are popular).
Unarchiving a TAR archive is a little like writing an English sentence, so it's nice and intuitive:
$ tar --extract --file crc-linux-X.YY.0-amd64.tar.xz
Pro tip: An easy way to avoid typing long archive names is to type the first few letters of the filename, followed by the asterisk (*) "wildcard" character, and then the end of filename. For example, tar --extract --file crc*tar.xz
is a lot faster than typing the full name of the archive.
6. sudo
As you use your Linux computer on a daily basis, you're using it as a normal user. As a result, you're protected from making surprise mistakes, like accidentally deleting libraries and commands your computer requires to work. That's an important safeguard, and it's protected many systems administrators from catastrophic data loss. Embrace the restriction.
However, sometimes you need to override the safety features and perform an action with administrative (or "super user") powers. To do that, you can type sudo
before any command to force your computer to prompt you for your password. Assuming you're an admin of the computer you're using, the safeguards are removed temporarily and your command is executed.
6. mv
When you download a command like oc
, your computer doesn't really know you've downloaded a new command. To your computer, you've just gathered some more binary data, which you do every day when you browse the Internet or save an office file to your hard drive. For your terminal to understand that something is a command, the file must be in your executable path.
You can see what directories are in your path with the echo
command:
$ echo $PATH /usr/local/bin:/usr/bin:/bin:
In this example, you have /usr/local/bin
first in your path, which means that your terminal looks in that folder first for any command you type. Should it fail to find that command there, it moves on to /usr/bin
, and then finally to /bin
.
The mv
command is designed to move files. When you want to move a command into your path, use the echo
command to view your path, and then use the mv
command with sudo
powers:
$ echo $PATH /usr/local/bin:/usr/bin:/bin: $ sudo mv oc /usr/local/bin
In this example, you use sudo mv
to move the oc
file to the first folder listed in your path. The syntax for mv
is always the source followed by the destination.
7. chmod
A command like oc
is a binary format. It's been compiled for a specific CPU architecture, and it runs when you type its name into your terminal.
A script, however, is more like a recipe. It's a list of commands for your computer to run without constant intervention. For your computer to do that, though, it requires your explicit permission. The chmod
command is how you grant that permission.
To grant a file called install.sh executable permission:
$ chmod +x install.sh
Now the file has permission to run as if it were a command.
8. Dot-slash (./)
To run a script you've just marked as executable, you can move it to your path using sudo
and mv
. But there's a shortcut. It's the dot-slash combination (./), and it indicates that a file you want to execute is in the current folder, not in your path.
$ ./install.sh
9. cd
The cd
command is how you change your current directory. When you open a terminal, you start in your home folder. If you work exclusively in your home directory, it tends to get cluttered pretty quickly. Instead, you can cd
to a subdirectory, like Downloads or Documents, and work there.
To change directory, type cd
followed by the directory path you want to navigate into:
$ cd Downloads
To go back home, use the tilde (~) as a shortcut:
$ cd ~
You can combine these to skip past directories all in one command. For instance, to navigate to the crc directory in your Downloads folder all in one giant leap, just string together the directory names:
$ cd ~/Downloads/crc
10. ls
The ls
command lists the contents of a directory. Suppose you've just downloaded and extracted an archive. To see what the package you've just unarchived contains, you use the ls
command:
$ curl https://github.com/okd-project/okd/releases/download/4.13.0-0.okd-2023-06-04-080300/openshift-client-linux-4.13.0-0.okd-2023-06-04-080300.tar.gz --remote-name $ tar --extract --file openshift-client*tar.gz $ ls README.md oc Kubectl
You've downloaded the oc
and kubectl
commands. You know how to move those to your path, and you’re even successfully using the rosa
command to create and manage clusters. You're well on your way to being a power user of the Linux terminal.
저자 소개
Seth Kenlon is a Linux geek, open source enthusiast, free culture advocate, and tabletop gamer. Between gigs in the film industry and the tech industry (not necessarily exclusive of one another), he likes to design games and hack on code (also not necessarily exclusive of one another).
채널별 검색
오토메이션
기술, 팀, 인프라를 위한 IT 자동화 최신 동향
인공지능
고객이 어디서나 AI 워크로드를 실행할 수 있도록 지원하는 플랫폼 업데이트
오픈 하이브리드 클라우드
하이브리드 클라우드로 더욱 유연한 미래를 구축하는 방법을 알아보세요
보안
환경과 기술 전반에 걸쳐 리스크를 감소하는 방법에 대한 최신 정보
엣지 컴퓨팅
엣지에서의 운영을 단순화하는 플랫폼 업데이트
인프라
세계적으로 인정받은 기업용 Linux 플랫폼에 대한 최신 정보
애플리케이션
복잡한 애플리케이션에 대한 솔루션 더 보기
오리지널 쇼
엔터프라이즈 기술 분야의 제작자와 리더가 전하는 흥미로운 스토리
제품
- Red Hat Enterprise Linux
- Red Hat OpenShift Enterprise
- Red Hat Ansible Automation Platform
- 클라우드 서비스
- 모든 제품 보기
툴
체험, 구매 & 영업
커뮤니케이션
Red Hat 소개
Red Hat은 Linux, 클라우드, 컨테이너, 쿠버네티스 등을 포함한 글로벌 엔터프라이즈 오픈소스 솔루션 공급업체입니다. Red Hat은 코어 데이터센터에서 네트워크 엣지에 이르기까지 다양한 플랫폼과 환경에서 기업의 업무 편의성을 높여 주는 강화된 기능의 솔루션을 제공합니다.