• Skip to main content

Uly.me

cloud engineer

  • Home
  • About
  • Search

linux

Memory Info on Linux

March 15, 2023

Here’s how to view system memory on Linux.

Default display is in kB

cat /proc/meminfo
MemTotal:        7492768 kB
MemFree:          427368 kB
MemAvailable:    5424768 kB

cat /proc/meminfo MemTotal: 7492768 kB MemFree: 427368 kB MemAvailable: 5424768 kB

Display in MB

awk '$3=="kB"{$2=$2/1024;$3="MB"} 1' /proc/meminfo | column -t
MemTotal:           7317.16      MB
MemFree:            404.527      MB
MemAvailable:       5285.4       MB

awk '$3=="kB"{$2=$2/1024;$3="MB"} 1' /proc/meminfo | column -t MemTotal: 7317.16 MB MemFree: 404.527 MB MemAvailable: 5285.4 MB

Output in GB

awk '$3=="kB"{$2=$2/1024^2;$3="GB";} 1' /proc/meminfo | column -t
MemTotal:           7.14566      GB
MemFree:            0.370392     GB
MemAvailable:       5.13733      GB

awk '$3=="kB"{$2=$2/1024^2;$3="GB";} 1' /proc/meminfo | column -t MemTotal: 7.14566 GB MemFree: 0.370392 GB MemAvailable: 5.13733 GB

Filed Under: Linux Tagged With: display, linux, meminfo, memory, proc

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

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

Copyright © 2023