0% found this document useful (0 votes)
17 views

Linux OS Basic Commands

A note on linux file management, text file manipulation, threading, c program execution and creation.

Uploaded by

sherajussalehin
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
17 views

Linux OS Basic Commands

A note on linux file management, text file manipulation, threading, c program execution and creation.

Uploaded by

sherajussalehin
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 3

Command action

whoami Shows username

pwd Current directory

ls Show current files and folders in PWD

cd Change working directory

mkdir Make new directory

cd .. Go to parent directory

cat>filename.txt Create and write in a text file

ctrl+d Exit editing

cat filename.txt Open a file

nl filename.txt Open a text file with line number

cp filename.txt directory Copy a text file to a directory

rm filename.txt Remove a file

mv filename.txt directory Move a file to a directory

Ls -a Show all files and folders including hidden


ones

ls regex Shows folders with matching regex pattern


with their sub files and folders

ls -l Show directions & paths with their


security(follow note)

chmod Change permissions of a file (follow note)

grep “string” filename.txt Marks and returns lines with matching string

grep -wi “string” filename.txt Returns string with exact match

grep -win “string” filename.txt Return exact match with line number

ln -s filename.txt newfilename.txt Create shortcut with softlink

ln filename.txt newfilename.txt Create shortcut with hardlink


touch filename.fileextention Create an empty file

gedit EDIT THE FILE

ctrl+c Stop editing via gedit

gcc -o ref-name filename.fileextention Compiles the filename and gives a reference


name

./ref-name Runs the program with reference name

Data types in c Also check drive

# random note # list in c itself is a reference, so it does not


require & before it in C operations.

# RANDOM NOTE 2 # GETCHAR , PUTCHAR

* BEFORE VARIABLE NAME MEANS


POINTERS AND REQUIRE ADDRESSES
OF VALUES.

‘/0’ in c list means end of list

Practice C struct

lseek(fd, 0, 0); Carriage return in c

static char message[] = " "; Write on txt file from char array
write(fd, message, sizeof(message));

char buffer[80]; Store data from txt file to char array


read(fd, buffer, sizeof(message));

gcc -pthread -o ref code.c Run a p-thread

void* block(void* arg){


}

pthread_create(&thread1,NULL,block1,NULL);

pthread_join(thread1,Null); Incase of loop thread creation, keep creation


and join in separate loops for parallel
execution

Threads share global variables.

Parent child processes are different process.


So they dont share global variables.

You might also like