martes, 17 de mayo de 2022

Tutorial de Linux y unix con Shell por Alexander Arias

Guardar las siguientes 192 lineas en un archivo, por ejemplo main.sh, luego ejecutarlo en la terminal de Linux,

Luego para ejecutarlo darle punto espacio el nombre: . main.sh

$. main.sh


echo 'Tutorial de Linux y unix con Shell'

echo 'Por: Alexander Arias'

echo 'Fecha: 2022-05-17'

echo 'Basado en parte de: Unix for the Beginning Mage A Tutorial by Joe Topjian'

echo Hello World

echo ------------ whoami

whoami

echo ------------ Print Working Directory

pwd

echo ------------

echo -- 'The tilde (~) is a nickname for your home -- weird'

echo -- "joe$ cd ~"

echo ' Change Directory -- $cd ..'

echo 'cd [path] Change Directory '

echo ------------

echo 'mkdir [name] Make Directory '

echo ------------

echo "$ ls -ls"

ls -ls

echo ------------

echo 'Con nano creo un archivo hola'

echo '$nano hola'

echo 'hola estoy con nano editor'

echo ------------

echo '$cat hola'

cat hola

echo ------------

echo 'Copying files'

echo '$cp hola hola1'

cp hola hola1

cat hola1

echo ------------

echo 'Making Folder'

echo '$makdir folder_hola'

mkdir folder_hola

ls

echo ------------

echo 'Moving File'

echo '$mv hola1 /folder_hola/hola2'

mv hola1 folder_hola/hola2

echo '$ls folder_hola'

ls folder_hola

echo 'cat folder_hola/hola2'

cat folder_hola/hola2

echo ------------

echo 'Deleting File'

echo '$rm archivo'

echo ------------

echo 'Deleting Folder'

echo '$rmdir folder'

echo ------------

echo 'Deleting All recursive (r) and force (f)'

echo '$rm -rf'

echo ------------

echo 'Clear Terminal'

echo '$clear'

echo ------------

echo 'Historically, the very first shell was known as sh.'

echo 'You can see what shell you?re using by echoing an environment variable.'

echo '$echo $SHELL'

echo $SHELL

echo ------------

echo 'Shell History'

echo '$history'

echo ' history'

echo '   1  history'

echo '    2  ls'

echo '    3  ls -ls'

echo '    4  history'

echo ------------

echo 'Command Completion'

echo 'What if you couldn?t remember how a command was spelled, but you knew it began with ca? With command completion, you can type the letters ca then press tab twice. A list of all the commands that start with ca will appear!'

echo ------------

echo 'Customizing Your Prompt'

echo 'joe$ PS1=”My New Prompt> “'

echo 'My New Prompt>'

echo ------------

echo 'cat [file1] ([file2]).. Concatenate Sends the output of one or more files to the screen'

echo ------------

echo 'less [file] Less Allows you to read a file with many pages easily'

echo ------------

echo 'more [file] More Allows you to read a file with many pages easily'

echo ------------

echo 'Viewing Partitions'

echo '$df'

df

echo ------------

echo '$df -h'

echo '-h option (which stands for Human Readable)'

df -h

echo ------------

echo 'Groups'

echo '$groups'

groups

echo ------------

echo '$ls -l'

echo '-l is another spell modifier that will show you lots of details about the files -- including the shields.'

ls -l

echo ------------

echo 'Permisos'

echo '- rwx rwx rwx'

echo 'UGO: User, Group, Other'

echo 'Owner (user) of the file, a Group, and Everyone Else (which we?ll call Other)'

echo ------------

echo 'Quitar permisos con menos -'

echo 'joe$ chmod g-w hola'

echo ------------

echo 'Asignar permisos con + mas'

echo 'ejemplos:'

echo 'joe$ chmod u+rwx hola'

echo 'joe$ chmod ugo+rx hola'

echo 'joe$ chmod u+x,g+rw,o-r shelf'

echo ------------

echo 'Using the Number Method to Place Shields on Files'

echo 'Next, you group three numbers together for a UGO combination. For example, if you wanted User to have Read and Write, Group to have Read and Execute, and Other to have Read, it would be 654. 6 = rw, 5 = rx, and 4 = r'

echo 'joe$ chmod 654 shelf'

echo ------------

echo 'Types of Files'

echo 'Letter What it is'

echo '     - Plain File'

echo '     d Directory'

echo '     l Link'

echo '     p Pipe'

echo '     b Block Device'

echo '     c Character Device'

echo ------------

echo 'ln [file1] [file2] Link Links two files together'

echo ------------

echo 'echo $PATH'

echo $PATH

echo ------------

echo 'grep'

echo ' should have been called grab since that´s what it does -- grabs text'

echo ------------

echo 'echo "HI" > hola3'

echo "HI" > hola3

echo 'cat hola3'

cat hola3

echo ------------

echo 'cat /etc/passwd'

cat /etc/passwd

echo ------------

grep runner /etc/passwd

echo ------------

echo 'Passwords'

echo 'grep runner /etc/shadow'

#grep runner /etc/shadow

echo ' error'

echo 'exit status 2'

echo ------------

echo 'to change your password in Unix'

echo 'joe$ passwd'

echo ------------

echo 'How To Become Root'

echo 'su sudo'

echo ------------

echo 'who Who Shows all mages currently in the Tower

passwd Password Changes your password'

echo 'chown Change Owner Changes the owner of a file'

echo 'su Switch User Switches you to another account'

echo 'sudo Superuser Do Allows you to run root commands'

echo ------------

echo 'Daemons (not demons!)'

echo 'Each daemon has a job to do and they only do that job. That?s it! Daemons just sit in the tower and wait until they have to do their job.'

echo ------------

echo 'Processes'

echo 'ps'

ps

echo 'ps -a'

ps -a

echo 'ps -ax'

ps -ax

echo 'ps -aux'

ps -aux

echo ------------

echo 'background'

echo 'top &'

top &

echo 'date &'

date &

echo 'jobs in background'

echo 'jobs'

jobs

echo ------------

echo 'foreground'

#fg 2

echo ------------

echo 'Killing Processes'

echo 'joe$ kill 699'

echo ------------

echo 'su Switch User Switches you to another account'

echo 'sudo Superuser Do Allows you to run root commands'



No hay comentarios:

Publicar un comentario