Linux commands

Here a short list of Linux commands that can be useful:
List content of a folder with permissions
ls -l

Go to folder usr
cd /usr

Make Directory – ie. Create a directory.
mkdir cognos
Remove Directory – ie. Delete a directory.
rmdir cognos
Create a blank file named index in folder db
touch db/index
Copy – ie. Copy a file or directory
Move – ie. Move a file or directory (can also be used to rename)
Remove – ie. Delete a file

Change permissions so only Root user have access to folder /root/ca
chmod 600 -R /root/ca

Change permission so all have access to file cognos
chmod 777 cognos

Change owner of a file to dockeruser
chown dockeruser:  filename

Shutdown a linux server
init 0

Restart of linux server
init 6

Linux command to list groups a user is part of
groups donald

Add a group to a exiting user
usermod -a -G examplegroup exampleusername

Create a new user and add it to a group
useradd -G examplegroup exampleusername

Set a password for the new user
passwd exampleusername

Change to a other user
su – exampleusername

To check if you can find server by DNS
ping servername

To install telnet in a centos distribution
yum install telnet

To check if port 9300 is open to server
telnet servername 9300

List firewall rules in Linux
iptables -L INPUT

Check if port 80 or 443 is open
netstat -ano|grep LISTEN

Add file1 to file2
cat file1.txt >> file2.txt

Change to a parallel folder
cd ../scripts/

Move several pem files to sub folder old
mv *.pem ./old/

Show cpu and memory usage

Show Top 7 Memory Consuming Process in Linux
ps -auxf | sort -nr -k 4 | head -7

Shutdown a centos linux server
/sbin/shutdown -h now

Create folder to use to connect to your windows host from a linux vmware image
sudo mkdir /media/source

Install software in centos to allow mount of windows shares
yum install cifs-utils

To connect “install” file share on windows server to above folder in Linux
sudo mount -t cifs -o username:donald,password=duck,vers=2.0  //   /media/source
IMPORTANT you need to enter vers=2.0 in some versions of Linux.
Change username and password to a local windows user that have access to the file share.

To extract a file
unzip -d destination_folder

Linux command to find ip address of server
/sbin/ifconfig | grep ‘inet’

Connect to other linux machine from linux (putty in windows)
ssh -Y root@

Set open files limit in Linux — cognos need to have a high value.
ulimit -n 8192

Install support for x – so you can see config
sudo yum install xorg-xll-xauth

Start of cognos configuration from ssh window

List free space on the hard drive
df  -h

Check if you have access to docker compose program by check version
docker-compose version

List all downloaded images
docker image ls

List all running process in docker
docker ps

List all installed process in docker
docker ps  –all

Kill a docker process (you need to enter a exact name, no wildcards)
docker kill admintool

Kill all running containers
docker kill $(docker ps -q)
Delete all stopped containers
docker rm $(docker ps -a -q)
Delete all images
docker rmi $(docker images -q)

Show cert file on screen, to check if it is correct
openssl  pkcs7  -print_certs  -in  certnew.p7b

Convert a certificate_chain_file.pfx file to pem format with the following command:
openssl  pkcs12  -in  c:\temp\your.pfx  -out  c:\temp\good.pem  -nodes

Change keyboard to swedish in Red Hat
localectl status
localectl set-keymap se

More information: