Difference between revisions of "Unix Linux Commands"

From The Dumping Ground
(Changed to new setting.)
(Added RedHat Enterprise Linux section.)
 
(9 intermediate revisions by the same user not shown)
Line 133: Line 133:
glennn@usnaplzena1:~$ sudo apt-get update
glennn@usnaplzena1:~$ sudo apt-get update
glennn@usnaplzena1:~$ sudo apt-get upgrade
glennn@usnaplzena1:~$ sudo apt-get upgrade
</pre>
==== List Installed Packages ====
<pre>
glennn@usnaplzena1:~$ sudo apt list --installed
</pre>
=== RedHat Enterprise Linux ===
==== Install ====
<pre>
$ sudo yum install <name>
</pre>
==== List Installed Packages ====
<pre>
$ sudo yum list installed
</pre>
</pre>


Line 145: Line 161:
<pre>
<pre>
glennn@TLINUXSUSE64:~> sudo systemctl reboot
glennn@TLINUXSUSE64:~> sudo systemctl reboot
</pre>
=== Ubuntu ===
<pre>
glennn@usnaplzena1:~$ sudo reboot now
</pre>
== Finding Files ==
=== Finding Files Modified Between Two Dates ===
<pre>
touch --date "2007-01-01" /tmp/start
touch --date "2008-01-01" /tmp/end
find /data/images -type f -newer /tmp/start -not -newer /tmp/end -exec ls -l '{}' \;
</pre>
=== Converting the Newline Format of Files ===
<pre>
find src -name *.cs -exec unix2dos '{}' \;
</pre>
== JAR Files ==
=== List All Directories in a JAR File as Packages ===
<pre>
jar tf myjar.jar | grep -v .class | grep -v .properties | grep -v .res | grep -v .dtd | grep -v META-INF | sed 's/\/$//g' | sed 's/\//./g' | sort
</pre>
</pre>

Latest revision as of 10:25, 23 April 2025

Getting Disk Usage Information

glennn@TLINUXSUSE64:~> df -h
Filesystem      Size  Used Avail Use% Mounted on
rootfs          7.8G  4.1G  3.3G  56% /
devtmpfs        239M   36K  239M   1% /dev
tmpfs           246M  320K  245M   1% /dev/shm
tmpfs           246M  524K  245M   1% /run
/dev/sda2       7.8G  4.1G  3.3G  56% /
tmpfs           246M     0  246M   0% /sys/fs/cgroup
tmpfs           246M  524K  245M   1% /var/lock
tmpfs           246M     0  246M   0% /media
tmpfs           246M  524K  245M   1% /var/run
/dev/sda3        12G  367M   11G   4% /home

Get IP Address

All Adapter Information

glennn@usnaplzena1:~$ ifconfig
eth0      Link encap:Ethernet  HWaddr 08:00:27:cb:df:55
          inet addr:10.5.2.56  Bcast:10.5.3.255  Mask:255.255.252.0
          inet6 addr: fe80::a00:27ff:fecb:df55/64 Scope:Link
          UP BROADCAST RUNNING MULTICAST  MTU:1500  Metric:1
          RX packets:4974212 errors:0 dropped:0 overruns:0 frame:0
          TX packets:13432 errors:0 dropped:0 overruns:0 carrier:0
          collisions:0 txqueuelen:1000
          RX bytes:437678596 (437.6 MB)  TX bytes:1739133 (1.7 MB)

lo        Link encap:Local Loopback
          inet addr:127.0.0.1  Mask:255.0.0.0
          inet6 addr: ::1/128 Scope:Host
          UP LOOPBACK RUNNING  MTU:65536  Metric:1
          RX packets:44701 errors:0 dropped:0 overruns:0 frame:0
          TX packets:44701 errors:0 dropped:0 overruns:0 carrier:0
          collisions:0 txqueuelen:0
          RX bytes:11919843 (11.9 MB)  TX bytes:11919843 (11.9 MB)

IPv4

glennn@usnaplzena1:~$ ifconfig eth0 | grep "inet addr:" | cut -f 2 -d ':' | cut -f 1 -d ' '
10.5.2.56

IPv6

glennn@usnaplzena1:~$ ifconfig eth0 | grep "inet6 addr:" | head -1 | tr -s ' ' | cut -f 4 -d ' ' | cut -f 1 -d '/'
fe80::a00:27ff:fecb:df55

Get Version Information

Kernel Version

glennn@usnaplzena1:~$ uname -r
3.13.0-43-generic

openSUSE Version

glennn@TLINUXSUSE64:~> cat /etc/os-release
NAME=openSUSE
VERSION="13.1 (Bottle)"
VERSION_ID="13.1"
PRETTY_NAME="openSUSE 13.1 (Bottle) (x86_64)"
ID=opensuse
ANSI_COLOR="0;32"
CPE_NAME="cpe:/o:opensuse:opensuse:13.1"
BUG_REPORT_URL="https://bugs.opensuse.org"
HOME_URL="https://opensuse.org/"
ID_LIKE="suse"
glennn@TLINUXSUSE64:~>

Ubuntu Version

glennn@usnaplzena1:~$ lsb_release -a
No LSB modules are available.
Distributor ID: Ubuntu
Description:    Ubuntu 14.04.1 LTS
Release:        14.04
Codename:       trusty

Installing & Updating Software

openSUSE

Install

glennn@TLINUXSUSE64:~> sudo zypper install <name>

Update

glennn@TLINUXSUSE64:~> sudo zypper up
Loading repository data...
Reading installed packages...

Nothing to do.

Distribution Update

glennn@TLINUXSUSE64:~> sudo zypper dup
Loading repository data...
Reading installed packages...
Computing distribution upgrade...

Nothing to do.

List Repositories

glennn@TLINUXSUSE64:~> sudo zypper lr
# | Alias                              | Name                               | Enabled | Refresh
--+------------------------------------+------------------------------------+---------+--------
1 | Updates-for-openSUSE-12.1-12.1-1.4 | Updates for openSUSE 12.1 12.1-1.4 | Yes     | Yes
2 | openSUSE-12.1-12.1-1.4             | openSUSE-12.1-12.1-1.4             | Yes     | No
3 | repo-debug                         | openSUSE-12.1-Debug                | No      | Yes
4 | repo-debug-update                  | openSUSE-12.1-Update-Debug         | No      | Yes
5 | repo-non-oss                       | openSUSE-12.1-Non-Oss              | Yes     | Yes
6 | repo-oss                           | openSUSE-12.1-Oss                  | Yes     | Yes
7 | repo-source                        | openSUSE-12.1-Source               | No      | Yes

Ubuntu

Install

glennn@usnaplzena1:~$ sudo apt-get install <name>

Update

glennn@usnaplzena1:~$ sudo apt-get update
glennn@usnaplzena1:~$ sudo apt-get upgrade

List Installed Packages

glennn@usnaplzena1:~$ sudo apt list --installed

RedHat Enterprise Linux

Install

$ sudo yum install <name>

List Installed Packages

$ sudo yum list installed

Starting Network Services

openSUSE

glennn@TLINUXSUSE64:~> sudo systemctl start network.service

Reboot System

openSUSE

glennn@TLINUXSUSE64:~> sudo systemctl reboot

Ubuntu

glennn@usnaplzena1:~$ sudo reboot now

Finding Files

Finding Files Modified Between Two Dates

touch --date "2007-01-01" /tmp/start
touch --date "2008-01-01" /tmp/end
find /data/images -type f -newer /tmp/start -not -newer /tmp/end -exec ls -l '{}' \;

Converting the Newline Format of Files

find src -name *.cs -exec unix2dos '{}' \;

JAR Files

List All Directories in a JAR File as Packages

jar tf myjar.jar | grep -v .class | grep -v .properties | grep -v .res | grep -v .dtd | grep -v META-INF | sed 's/\/$//g' | sed 's/\//./g' | sort