• Skip to main content

Uly.me

cloud engineer

  • Home
  • About
  • Archives

linux

Rocky Linux in a Container

November 7, 2021

Here’s how to run Rocky Linux in a Docker container.

Download the image.

docker pull rockylinux/rockylinux

docker pull rockylinux/rockylinux

Create a Rocky Linux container called bullwinkle.

docker run -it --name bullwinkle -d rockylinux/rockylinux

docker run -it --name bullwinkle -d rockylinux/rockylinux

Login to the container using bash.

docker exec -it --user root bullwinkle /bin/bash

docker exec -it --user root bullwinkle /bin/bash

When done, stop and delete the container.

docker ps -a
docker stop container_ID
docker rm container_ID

docker ps -a docker stop container_ID docker rm container_ID

Filed Under: Linux Tagged With: bash, container, docker, linux, pull, rocky

Useradd With Specific uid and guid

November 5, 2021

Here’s the command to create a Linux user with a specific user id and group id.

sudo groupadd -r -g 1234567 username
sudo useradd -r -u 1234567 -g 1234567 -m -d /home/username -s /bin/bash nexus -c "my new account"

sudo groupadd -r -g 1234567 username sudo useradd -r -u 1234567 -g 1234567 -m -d /home/username -s /bin/bash nexus -c "my new account"

Filed Under: Linux Tagged With: create, guid, home, linux, uid, user, useradd

Printing From A Terminal

July 7, 2020

There are times you just want to print directly from the command line.

# check your printing options
lpotions
lpinfo -v
# what's your default printer
lpinfo -p -d
# use lp to print
lp notes.txt
# use -n print multiple copies
lp -n 2 notes.txt
# check the printer queue
lp -q
# use the job number to cancel print jobs if needed
cancel 123

# check your printing options lpotions lpinfo -v # what's your default printer lpinfo -p -d # use lp to print lp notes.txt # use -n print multiple copies lp -n 2 notes.txt # check the printer queue lp -q # use the job number to cancel print jobs if needed cancel 123

Filed Under: Linux Tagged With: cancel, command line, cups, linux, print, queue

Linux Prompt

January 20, 2020

Here’s my favorite Linux prompt.

PS1='\[\033[01;32m\]\u@\h\[\033[00m\]:\[\033[01;34m\]\w\[\033[00m\]\$ '

PS1='\[\033[01;32m\]\u@\h\[\033[00m\]:\[\033[01;34m\]\w\[\033[00m\]\$ '

Add to end of your .bashrc to make it permanent.

Filed Under: Linux Tagged With: colors, directory, hostname, linux, prompt, username

Rsync only new files

September 9, 2019

Here’s how to sync files between two directories, while copying only new files and ignoring existing files.

rsync --ignore-existing -rapzvh /dir1 /dir2 >> /root/rsync.log &

rsync --ignore-existing -rapzvh /dir1 /dir2 >> /root/rsync.log &

Filed Under: Linux Tagged With: existing files, ignore, linux, rsync

View contents of tar file

September 8, 2019

Here’s how to view the contents of a tar file without extracting the files.

tar -tvf file.tar

tar -tvf file.tar

Filed Under: Linux Tagged With: extracting, linux, tar, view, without

Get Directory Size

September 7, 2019

Here’s how to get the size of a directory.

du -sh /var/www

du -sh /var/www

Output:

2.1GB    /var/www

2.1GB /var/www

Size of the directories and files one level down.

du -sh /var/www/*

du -sh /var/www/*

Sort with biggest files from top to bottom.

du -sh /var/www/* | sort -rh

du -sh /var/www/* | sort -rh

Top 5 biggest files from top to bottom.

du -sh /var/www/* | sort -rh | head -5

du -sh /var/www/* | sort -rh | head -5

Filed Under: Linux Tagged With: directory, linux, size

Install Docker on Linux

July 4, 2019

How to install Docker on Linux Mint or Ubuntu.

sudo apt-get install docker-ce docker-ce-cli containerd.io
docker --version

sudo apt-get install docker-ce docker-ce-cli containerd.io docker --version

Filed Under: Cloud Tagged With: docker, install, linux, mint, ubuntu

  • Go to page 1
  • Go to page 2
  • Go to Next Page »
  • Home
  • About
  • Archives

Copyright © 2023