Skip to content
Snippets Groups Projects
Commit b2093cfb authored by Peter Gerwinski's avatar Peter Gerwinski
Browse files

Sommersemester 2023

parent 9cd23492
No related branches found
No related tags found
No related merge requests found
Showing with 0 additions and 321 deletions
ls: Zugriff auf 'bla.txt' nicht möglich: Datei oder Verzeichnis nicht gefunden
-rw-r--r-- 1 peter peter 20 Mär 28 13:14 test.txt
cassini/home/peter/bo/2022ss/bs/20220328> cat test.bc
1 + 1
cassini/home/peter/bo/2022ss/bs/20220328> bc < test.bc
2
cassini/home/peter/bo/2022ss/bs/20220328> echo "2 + 2" | bc
4
cassini/home/peter/bo/2022ss/bs/20220328> cat test.txt
Test
Noch ein Test.
cassini/home/peter/bo/2022ss/bs/20220328> cat test.txt | sed -e 's/Test/Toast/g'
Toast
Noch ein Toast.
cassini/home/peter/bo/2022ss/bs/20220328> cat test.txt | gzip
gzip: compressed data not written to a terminal. Use -f to force compression.
For help, type: gzip -h
cassini/home/peter/bo/2022ss/bs/20220328> cat test.txt | gzip -f
7�Ab
I-.���O�PH����s�d-cassini/home/peter/bo/2022ss/bs/20220328> cat test.txt | gzip | gunzip
Test
Noch ein Test.
cassini/home/peter/bo/2022ss/bs/20220328> cat test.txt | gzip | cat | gunzip
Test
Noch ein Test.
cassini/home/peter/bo/2022ss/bs/20220328> cat test.txt | gzip > test.txt.gz
cassini/home/peter/bo/2022ss/bs/20220328> cat test.txt.gz
w�Ab
I-.���O�PH����s�d-cassini/home/peter/bo/2022ss/bs/20220328> cat test.txt.gz | gunzip
Test
Noch ein Test.
cassini/home/peter/bo/2022ss/bs/20220314> ls *.pdf
bs-20220314.pdf logo-hochschule-bochum.pdf unix-20220314.pdf
logo-hochschule-bochum-cvh-text.pdf Operating_system_placement-de.pdf
cassini/home/peter/bo/2022ss/bs/20220314> ls *.pdf | grep -v logo
bs-20220314.pdf
Operating_system_placement-de.pdf
unix-20220314.pdf
cassini/home/peter/bo/2022ss/bs/20220314> echo $(ls *.pdf | grep -v logo)
bs-20220314.pdf Operating_system_placement-de.pdf unix-20220314.pdf
cassini/home/peter/bo/2022ss/bs/20220314> ls -l $(ls *.pdf | grep -v logo)
-rw-r--r-- 1 peter peter 132739 Mär 13 22:24 bs-20220314.pdf
lrwxrwxrwx 1 peter peter 43 Apr 17 2016 Operating_system_placement-de.pdf -> ../common/Operating_system_placement-de.pdf
-rw-r--r-- 1 peter peter 149583 Mär 21 15:16 unix-20220314.pdf
-rw-r--r-- 1 peter peter 20 Mär 28 13:14 test.txt
cassini/home/peter/bo/2022ss/bs/20220328> ls -l test.txt
-rw-r--r-- 1 peter peter 20 Mär 28 13:14 test.txt
cassini/home/peter/bo/2022ss/bs/20220328> ls -l test.txt bla.txt
ls: Zugriff auf 'bla.txt' nicht möglich: Datei oder Verzeichnis nicht gefunden
-rw-r--r-- 1 peter peter 20 Mär 28 13:14 test.txt
cassini/home/peter/bo/2022ss/bs/20220328> ls -l test.txt bla.txt >> ls.txt
ls: Zugriff auf 'bla.txt' nicht möglich: Datei oder Verzeichnis nicht gefunden
cassini/home/peter/bo/2022ss/bs/20220328> ls -l test.txt bla.txt 2> ls.err
-rw-r--r-- 1 peter peter 20 Mär 28 13:14 test.txt
cassini/home/peter/bo/2022ss/bs/20220328> cat ls.err
ls: Zugriff auf 'bla.txt' nicht möglich: Datei oder Verzeichnis nicht gefunden
cassini/home/peter/bo/2022ss/bs/20220328> ls -l test.txt bla.txt > ls.both 2>&1
cassini/home/peter/bo/2022ss/bs/20220328> cat ls.both
ls: Zugriff auf 'bla.txt' nicht möglich: Datei oder Verzeichnis nicht gefunden
-rw-r--r-- 1 peter peter 20 Mär 28 13:14 test.txt
1 + 1
Test
Noch ein Test.
File deleted
cassini/home/peter/bo/2022ss/bs/20220314> ls *.txt
for-1.txt if-0.txt if-2.txt pipes-2.txt test.txt
for-2.txt if-1.txt if-3.txt test-2.txt
cassini/home/peter/bo/2022ss/bs/20220314> echo mv -i {for,if,pipes}-*.txt ../20220321/
mv -i for-1.txt for-2.txt if-0.txt if-1.txt if-2.txt if-3.txt pipes-2.txt ../20220321/
cassini/home/peter/bo/2022ss/bs/20220314> mv -i {for,if,pipes}-*.txt ../20220321/
cassini/home/peter/bo/2022ss/bs/20220321> ls *.txt
for-1.txt if-0.txt if-2.txt pipes-2.txt test-2.txt test-4.txt
for-2.txt if-1.txt if-3.txt test-1.txt test-3.txt wildcards-1.txt
cassini/home/peter/bo/2022ss/bs/20220321> ls *.txt | grep -v test
for-1.txt
for-2.txt
if-0.txt
if-1.txt
if-2.txt
if-3.txt
pipes-2.txt
wildcards-1.txt
cassini/home/peter/bo/2022ss/bs/20220321> echo mv $(ls *.txt | grep -v test) ../20220328/
mv for-1.txt for-2.txt if-0.txt if-1.txt if-2.txt if-3.txt pipes-2.txt wildcards-1.txt ../20220328/
cassini/home/peter/bo/2022ss/bs/20220321> mv $(ls *.txt | grep -v test) ../20220328/
Makefile-modules
\ No newline at end of file
philosophy: philosophy.o answer.o
gcc philosophy.o answer.o -o philosophy
answer.o: answer.c answer.h
gcc -Wall -O answer.c -c
philosophy.o: philosophy.c answer.h
gcc -Wall -O philosophy.c -c
TARGET = philosophy
OBJECTS = philosophy.o answer.o
HEADERS = answer.h
CFLAGS = -Wall -O
$(TARGET): $(OBJECTS)
gcc $(OBJECTS) -o $(TARGET)
answer.o: answer.c $(HEADERS)
gcc $(CFLAGS) answer.c -c
philosophy.o: philosophy.c $(HEADERS)
gcc $(CFLAGS) philosophy.c -c
clean:
rm -f $(OBJECTS) $(TARGET)
TARGET = philosophy
OBJECTS = philosophy.o answer.o
HEADERS = answer.h
CFLAGS = -Wall -O
$(TARGET): $(OBJECTS)
gcc $(OBJECTS) -o $(TARGET)
%.o: %.c $(HEADERS)
gcc $(CFLAGS) $< -c
clean:
rm -f $(OBJECTS) $(TARGET)
TARGET = philosophy
OBJECTS = philosophy.o answer.o
HEADERS = answer.h
CFLAGS = -Wall -O
all: $(TARGET)
$(TARGET): $(OBJECTS)
gcc $(OBJECTS) -o $(TARGET)
%.o: %.c $(HEADERS)
gcc $(CFLAGS) $< -c
clean:
rm -f $(OBJECTS) $(TARGET)
obj-m += hellomod-1.o
obj-m += hellomod-2.o
obj-m += chardev-1.o
all:
make -C /lib/modules/$(shell uname -r)/build M=$(PWD) modules
clean:
make -C /lib/modules/$(shell uname -r)/build M=$(PWD) clean
#include "answer.h"
int answer (void)
{
return ANSWER;
}
extern int answer (void);
#define ANSWER 42
/*
* chardev.c: Creates a read-only char device that says how many times
* you've read from the dev file
*/
#include <linux/kernel.h>
#include <linux/module.h>
#include <linux/fs.h>
#include <asm/uaccess.h> /* for put_user */
/*
* Prototypes - this would normally go in a .h file
*/
int init_module(void);
void cleanup_module(void);
static int device_open(struct inode *, struct file *);
static int device_release(struct inode *, struct file *);
static ssize_t device_read(struct file *, char *, size_t, loff_t *);
static ssize_t device_write(struct file *, const char *, size_t, loff_t *);
#define SUCCESS 0
#define DEVICE_NAME "chardev" /* Dev name as it appears in /proc/devices */
#define BUF_LEN 80 /* Max length of the message from the device */
/*
* Global variables are declared as static, so are global within the file.
*/
static int Major; /* Major number assigned to our device driver */
static int Device_Open = 0; /* Is device open?
* Used to prevent multiple access to device */
static char msg[BUF_LEN]; /* The msg the device will give when asked */
static char *msg_Ptr;
static struct file_operations fops = {
.read = device_read,
.write = device_write,
.open = device_open,
.release = device_release
};
/*
* This function is called when the module is loaded
*/
int init_module(void)
{
Major = register_chrdev(0, DEVICE_NAME, &fops);
if (Major < 0) {
printk(KERN_ALERT "Registering char device failed with %d\n", Major);
return Major;
}
printk(KERN_INFO "I was assigned major number %d. To talk to\n", Major);
printk(KERN_INFO "the driver, create a dev file with\n");
printk(KERN_INFO "'mknod /dev/%s c %d 0'.\n", DEVICE_NAME, Major);
printk(KERN_INFO "Try various minor numbers. Try to cat and echo to\n");
printk(KERN_INFO "the device file.\n");
printk(KERN_INFO "Remove the device file and module when done.\n");
return SUCCESS;
}
/*
* This function is called when the module is unloaded
*/
void cleanup_module(void)
{
/*
* Unregister the device
*/
unregister_chrdev(Major, DEVICE_NAME);
}
/*
* Methods
*/
/*
* Called when a process tries to open the device file, like
* "cat /dev/mycharfile"
*/
static int device_open(struct inode *inode, struct file *file)
{
static int counter = 0;
if (Device_Open)
return -EBUSY;
Device_Open++;
sprintf(msg, "I already told you %d times Hello world!\n", counter++);
msg_Ptr = msg;
try_module_get(THIS_MODULE);
return SUCCESS;
}
/*
* Called when a process closes the device file.
*/
static int device_release(struct inode *inode, struct file *file)
{
Device_Open--; /* We're now ready for our next caller */
/*
* Decrement the usage count, or else once you opened the file, you'll
* never get get rid of the module.
*/
module_put(THIS_MODULE);
return 0;
}
/*
* Called when a process, which already opened the dev file, attempts to
* read from it.
*/
static ssize_t device_read(struct file *filp, /* see include/linux/fs.h */
char *buffer, /* buffer to fill with data */
size_t length, /* length of the buffer */
loff_t * offset)
{
/*
* Number of bytes actually written to the buffer
*/
int bytes_read = 0;
/*
* If we're at the end of the message,
* return 0 signifying end of file
*/
if (*msg_Ptr == 0)
return 0;
/*
* Actually put the data into the buffer
*/
while (length && *msg_Ptr) {
/*
* The buffer is in the user data segment, not the kernel
* segment so "*" assignment won't work. We have to use
* put_user which copies data from the kernel data segment to
* the user data segment.
*/
put_user(*(msg_Ptr++), buffer++);
length--;
bytes_read++;
}
/*
* Most read functions return the number of bytes put into the buffer
*/
return bytes_read;
}
/*
* Called when a process writes to dev file: echo "hi" > /dev/hello
*/
static ssize_t
device_write(struct file *filp, const char *buff, size_t len, loff_t * off)
{
printk(KERN_ALERT "Sorry, this operation isn't supported.\n");
return -EINVAL;
}
File deleted
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment