Wednesday, 4 January 2012

Basic Linux Commands, Ubuntu Commands

  Show the present working directory

  Show the current user's session information in long format
  ps -l

  Show the current user's group membership
  id -g; id –gn

  Show the current user's PATH
  echo $PATH;

  List the contents of /boot in long format in three ways:
  Calling ls with an absolute path
  ls -l /boot;
  Calling ls with a relative path
  ls -l ../../boot;
  Changing directory to /boot and calling ls
  cd /boot ;ls -l

  Make a directory in the current user's home directory called lab2
  mkdir lab2

  Make two files in the lab2 directory: test and .test
   cd lab2; vi test; vi .test;  OR touch test ; touch .test;
  touch lab2/test ; touch lab2/.test; ls –alr lab2

  Make directory in the lab2 directory named sub1
  mkdir lab2/sub1; ls -alr lab2

  Change the permissions on test so only the owner can read and write the file and the file is not executable
  chmod 600 lab2/test; ls -alr lab2;

  Change the permissions on .test so the file is globally readable, write-protected, and globally executable
  chmod 707 lab2/.test; ls –alr lab2;

  List all processes for the current user and store the results into test
  who >> lab2/test ; ps –u $USER >> lab2/test;

  Use head to show the first line in test
  head -1 lab2/test

  Use tail to show the last line in test
  tail -1 lab2/test

  Use cat to show the contents of test
  cat lab2/test

  Change to the current user's home directory
  cd ~ OR cd

  Use find to recursively list the lab2 directory
  find lab2;

  Use ls to recursively list the lab2 directory
  ls -alr lab2

  Use rmdir to delete the sub1 directory
  rmdir lab2/sub1

  Use rm to delete the lab2 directory recursively
  rm –r lab2



Post a Comment

Free Host | lasik surgery new york